Thursday, February 15, 2018

windows 7 - What's the difference between the following cmd scripts?



I've tried launching several programs through a batch file and encountered problems but that is in the past.



I'm relatively new to scripts and command lines and this would be my question:
What's the difference between the following cmd scripts?



This one is accepted



Start Chrome



(i'm guessing here that some installed programs are recognized by title, even though the dir is not where the chrome.exe is the program still launches, registry keys play a part in this?)



this one works also



cd "FOO_DIR"
start FOO.exe



however these don't



start "FOO_DIR\FOO.exe"


(opens a new window without launching FOO.exe)



start /B "FOO_DIR\FOO.exe"



(writes the copyright text again and does nothing else)



(OS Windows 7 x64)


Answer



Start Chrome


This one works, because Chrome's executable is located in a folder which is in the PATH environment variable. start looks for programs in all folders in that variable. The environment variable PATHEXT contains a list of file extensions to look for and as .exe is contained by default, you don't need to write chrome.exe.







start "FOO_DIR\FOO.exe"


This does not work, because start will use its first argument as the window title if it is quoted. So this will open a new CMD with "FOO_DIR\FOO.exe" as its title.



To circumvent this, you can simply add an empty title argument before your command:



start "" "FOO_DIR\FOO.exe"


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...