Running 2 commands on a windows cmd line

A friend over Facebook messaged me today and asked “how can I run two commands on the same line?”…specifically, the question was how can I stop a service and start a service on the one single command line? And no…not using Windows PowerShell!!!

Well, yes it’s possible to do this on the command line, although it’s personally something that I never use.

So let’s use the SCOM healthservice as our example service.

We can stop the healthservice using the net stop command.

net stop healthservice

We can start it using the net start command.

net start healthservice

We can also issue both commands on the same line if we’d prefer:

cmd /c "net stop healthservice & net start healthservice"

And that will stop, then start the healthservice. So there you have it. If there’s a better way to do this, feel free to let me know about it.



No comments yet.

Leave a Reply