I know that you can run two commands in sequence, with one line, by putting && between them like this:

hostname && w32tm /query /configuration

However, this && function has a limitation: It only executes the second command if the first is successful.

My preferred use for && is to run informational commands directly from Start->Run (or Win+R) without having to type them into the CMD window or worry about the CMD console exiting prematurely. For example:

cmd /c hostname && w32tm /query /configuration && pause

Due to the aforementioned limitation though, this command will automatically exit the console window if w32tm fails - i.e.: If the Windows Time service is not running.

Is there a similar operator I can use to string commands together on one line, which will allow the second command to run even if the first errors out?

I'm looking for this to be compatible from Windows XP upward.


Just use & instead of &&. The second command will be executed even if the first one fails.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.