Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

20
  • 21
    Works on Win 8.0 and 8.1 as well. Commented Nov 25, 2013 at 8:53
  • 6
    @Fallenreaper, that does work in the straight cmd prompt as well, so I suppose it's not a bad habit to get into. :) Commented Jul 16, 2014 at 22:50
  • 6
    @Fallenreaper Make sure that you are aware of the practical difference between the two: See Raihan's answer below. Commented Jul 23, 2014 at 19:30
  • 12
    Got ya. A && B, B only will run if A is successful, whereas A & B will run B after A, no matter what the outcome of A is. Thanks for the heads up Commented Jul 25, 2014 at 18:44
  • 6
    @infografnet That's a different issue. Both commands are run, but the environment variable substitutions are evaluated before either command is actually executed. So echo %myvar% will be run as echo OldValueOfMyVar. This problem can be resolved by using the Delayed Expansion feature (only available in batch files though). So try the following inside a batch file: setlocal EnableDelayedExpansion && set MyVar=MyVal && echo !MyVar! && endlocal. (NOTE: The feature requires you to use ! marks in place of the % symbols. Commented Oct 22, 2014 at 12:59