Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 11 down vote accepted

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

share|improve this answer
5  
Here is the documentation for it: microsoft.com/resources/documentation/windows/xp/all/proddocs/… –  Oliver Salzburg May 23 '12 at 17:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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