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 often use a command line application. Its path is defined in the environment options, so in the PATH variable. When I manually launch the console and if I type the program name, it's launched.

For example, I type theprogram -option1 -option2 then it's launched with whatever the working directory is. (the .exe path is resolved by the PATH environment).

If I write the same in a .bat file, Windows brings up a message box saying it cannot find the program. In the .bat file there is start theprogram -option1 -option2, but I get the error message. So it seems that the PATH variable is not used in a .bat/.cmd file.

How can I launch theprogram from a .bat file, without specifying the full path? Does Windows 7 disable the PATH variable in .bat/.cmd files ?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I do this all the time on Windows 7 without any problems. Try leaving out the 'start' instruction and just run the program in the batch file using the program name directly, e.g.

theprogram -option1 -option2

don't forget to use quotes if there is a space in the name or path, e.g.

"the program" -option1 -option2

If that still doesn't work try running a very simple batch file to check your environment vars are loading correctly, e.g. save this as a batch file and run it:

set
pause
share|improve this answer
1  
The OP states in his question that be has already tried this. –  Dennis Feb 28 '13 at 16:39
1  
@Dennis not from my reading of the question. He uses 'start' to run the program not just the program name. I've expanded the answer a little. –  snowdude Feb 28 '13 at 16:42
    
Yes snwodude, it's true, but actually now it's working. I thing that's because I've reboot since it was failling...The PC involved is running 24/24.Maybe there is s a kind of limitation when modfying the PATH variable: you can use it directly in a console but you must reboot to get the new PATH item handled in bat files ? Anyway it's OK now. –  Kloze Feb 28 '13 at 16:43
1  
> I type theprogram -option1 -option2 then it's launched whatever the working dir is. [...] If I write the same in a bat file, Windows bangs a messagebox saying it cannot find the program. –  Dennis Feb 28 '13 at 16:43
    
It's OK Dennis, it seems that the problem was caused because the system was not rebooted after the PATH modification... –  Kloze Feb 28 '13 at 16:47

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.