kumarkumar Posted January 25, 2010 Posted January 25, 2010 I am trying to run a simple batch file where I would use it to run another exe.@ECHO OFFSTART %USERPROFILE%\Desktop\some.exeThis doesn't work. I get the error "Windows cannot find "C:\Documents'. Make sure you types the name correctly........"I guess this is because there are spaces in "Documents and Settings".I tried @ECHO OFFSTART "%USERPROFILE%\Desktop\some.exe"This doesn't work either. It opens command prompt and stays as it is.I tried@ECHO OFFSTART "%USERPROFILE%"\Desktop\some.exeThis doesn't work either. It opens command prompt and stays as it is.Wherever there is space in the path to exe, START command doesn't work (ex. %PROGRAMFILES%, %CD%, %TEMP%, etc) What could be wrong?
MrJinje Posted January 25, 2010 Posted January 25, 2010 (edited) I think Jaclaz got this one. Edited January 25, 2010 by MrJinje
jaclaz Posted January 25, 2010 Posted January 25, 2010 START often needs a "title" to work:http://ss64.com/nt/start.htmlIf there is a space in the path to the command, it must be enclosed in double quotes.Check if userprofile is definedI.E::SET USERPROFILEPAUSESTART "Window Title" "%USERPROFILE%\Desktop\some.exe"jaclaz
kumarkumar Posted January 25, 2010 Author Posted January 25, 2010 (edited) Thanks jaclaz. Adding "title" did the trick.I can use just one line in the batch file for my job (to make things more simpler) START "" "%USERPROFILE%\Desktop\some.exe"The following combinations of double quotes also workSTART "" "%USERPROFILE%"\Desktop\some.exeSTART "" "%USERPROFILE%"\Desktop\some.exe"START "" "%USERPROFILE%""\Desktop\some.exe"@MrJinjeI wanted to use START command and not just "%USERPROFILE%\Desktop\some.exe"(which would also run some.exe), because I wanted the cmd window to close automatically after it had opened some.exe, which is not possible without START command. Edited January 25, 2010 by kumarkumar
jaclaz Posted January 25, 2010 Posted January 25, 2010 (edited) The following combinations of double quotes also workNo matter if they work or not, DO NOT use them , use the first one: one single set of double quotes wrapping around the WHOLE path\exe.SYNTAX is there to be respected, not "invented", the first "wrong" example works only because you do not have a space in \Desktop\some.exe and the second (the one with the odd double quote) only works because of a "parsing defect" of the command interpreter, don't trust it.Third is pointless, it only adds to extra unneeded characters. jaclaz Edited January 25, 2010 by jaclaz
kumarkumar Posted January 27, 2010 Author Posted January 27, 2010 START often needs a "title" to work:http://ss64.com/nt/start.htmlIf there is a space in the path to the command, it must be enclosed in double quotes.Check if userprofile is definedI.E::SET USERPROFILEPAUSESTART "Window Title" "%USERPROFILE%\Desktop\some.exe"jaclazJust a small correctionIf I were to follow the START syntax correctly shouldn't it be @ECHO OFFSTART "%USERPROFILE%\Desktop" some.exe /h(with a space between the path and exe)
jaclaz Posted January 27, 2010 Posted January 27, 2010 Just a small correctionIf I were to follow the START syntax correctly shouldn't it be @ECHO OFFSTART "%USERPROFILE%\Desktop" some.exe /h(with a space between the path and exe)NO. That line would give a title of "%USERPROFILE%\Desktop" to the window.The "/h" is a paremeter to "some.exe".Read again the given link.command : The command, batch file or executable program to runcommand means the name of executable, including a fully qualified path to it UNLESS:the program is in the SAME directory as the running batchthe program is anywhere in the PATHA GENERAL rule about command line and batch parsing is that the SPACE is a separator, thus a full path containing spaces MUST be enclosed in double quotes.A workaround is using 8.3 compliant names, but this can generate "colliding" paths. (hint: use DIR /X)Don't be tricked by the optional [/Dpath] option that sets the "working directory", not the target to be executed.jaclaz
kumarkumar Posted January 27, 2010 Author Posted January 27, 2010 (edited) My bad a typoThe correct syntax should have been (following the suggestions in http://ss64.com/nt/start.html)@ECHO OFFSTART "Some Title" "%USERPROFILE%\Desktop" some.exe /h(where /h is the parameter to some.exe)Now if you look at any example in that website you would notice a space after the "path to the exe" and the "exe"START "My Login Script" /Min Login.cmdSTART "" /wait MySlowProgram.exe Edited January 27, 2010 by kumarkumar
Yzöwl Posted January 27, 2010 Posted January 27, 2010 No it shouldn't, here are all of the examples on that page:START "My Login Script" /Min Login.cmdSTART "" /wait MySlowProgram.exeSTART \\print_server\printer_nameSTART /Dc:\Documents\ /MAX notepad.exestart /wait /b First.exestart /wait /b Second.exestart /wait /b Third.exeNowhere does a path terminate then include a space before the name of the executable file. It also does not in the example you've provided.Since some.exe is located at the path %USERPROFILE%\Desktop you'd use the following:@START "Some Title" "%USERPROFILE%\Desktop\some.exe" /h
jaclaz Posted January 27, 2010 Posted January 27, 2010 (edited) Since some.exe is located at the path %USERPROFILE%\Desktop you'd use the following:@START "Some Title" "%USERPROFILE%\Desktop\some.exe" /h...should kumarkumar be willing to follow the advice he asked for..... jaclaz Edited January 27, 2010 by jaclaz
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now