2

I'm trying to do such task:

  • Setup git in path environment
  • Run bower

I want to do that as single command: cmd.exe /c "set PATH=%PATH%;c:\git && bower.cmd"

Unfortunately it doesn't work. For some reason the path variable doesn't change.

Does any body know why?

3
  • "In a batch file the default behaviour is to read and expand variables one line at a time, if you use & to run multiple commands on a single line, then any variable changes will not be visible until execution moves to the next line." from ss64.com/nt/syntax-redirection.html
    – DavidPostill
    Feb 3, 2016 at 11:19
  • You can either create a new batch file with the commands on separate lines, or set the path inside bower.cmd
    – DavidPostill
    Feb 3, 2016 at 11:21
  • @DavidPostill In a batch file ... any variable changes will not be visible until execution moves to the next line That's correct as far as %variable% expansion goes in the batch file itself. But the commands are still executed sequentially with immediate effect, so any subsequent command will see the just updated variable. That's easiest to verify if testing with a non-pre-existent environment variable, for example set "aaa=zzz" && set aaa will display aaa=zzz at the prompt.
    – dxiv
    Feb 4, 2016 at 8:11

1 Answer 1

3

Try instead:

cmd.exe /c "set "PATH=%PATH%;c:\git" && bower.cmd"

The way it was written without the extra pair of quotes around set "PATH=%PATH%;c:\git", what was appended to the PATH was C:\git+ a space at the end.

1
  • It looks like the space at the end was the issue Feb 4, 2016 at 7:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .