Octopuss Posted June 23, 2013 Share Posted June 23, 2013 (edited) I have a few questions about batch files I can't seem to google any clear answer to.When starting unspecified programs from a .cmd batch file, does it make any difference if I use start command or not?What's the difference between "start xyz.exe" and "cmd xyz.exe"? Both seem to be doing the same thing, but I do know there are some major differences there. I also see both being used at the same time, sometimes (like in the case of starting batch files from Windows 7's answer file for example).Basically, starting a program can be done by just using the .exe's name, by using cmd command, by using start command, or by combination of the last two. I am completely lost. Help! Edited June 23, 2013 by TheWalrus Link to comment Share on other sites More sharing options...
Yzöwl Posted June 23, 2013 Share Posted June 23, 2013 You're not starting unspecified programs, you're specifying them! Link to comment Share on other sites More sharing options...
Octopuss Posted June 24, 2013 Author Share Posted June 24, 2013 Huh? I have no idea what are you talking about. Link to comment Share on other sites More sharing options...
Tripredacus Posted June 24, 2013 Share Posted June 24, 2013 Sounds like you said "unspecified programs" but you could have just said "programs" ... http://www.computerhope.com/starthlp.htm Link to comment Share on other sites More sharing options...
Yzöwl Posted June 24, 2013 Share Posted June 24, 2013 I was being as vague as your question because there is no answer for unspecified programs, only for specified ones. You didn't specify any therefore we cannot provide you a definitive answer.As a general rule for running GUI applications from a batch file neither start or cmd have much purpose for you. Link to comment Share on other sites More sharing options...
Octopuss Posted June 24, 2013 Author Share Posted June 24, 2013 (edited) lol. I was trying to be as general as possible, and I overshot Basically I meant some random .exe, typically an installer of some sort, but I really wanted to avoid going into specifics. Edited June 24, 2013 by TheWalrus Link to comment Share on other sites More sharing options...
bphlpt Posted June 25, 2013 Share Posted June 25, 2013 So you are asking what in general the practical differences are in the results from the following 4 different statements when they are made inside a .cmd batch file, correct?1) xyz.exe2) cmd xyz.exe3) start xyz.exe4) cmd start xyz.exeAnd I assume you are curious under which circumstances you should use each format?Cheers and Regards Link to comment Share on other sites More sharing options...
Octopuss Posted June 25, 2013 Author Share Posted June 25, 2013 I would say so, yes. Link to comment Share on other sites More sharing options...
Yzöwl Posted June 25, 2013 Share Posted June 25, 2013 There is no definitive answer here it is often dependant upon the specific .exe,But generally, for installers from a batch file, there is no reason to prepend with cmd, even less reason to prepend with cmd and start and unless you have issues simply invoking the installer directly, no real reason to use start. Link to comment Share on other sites More sharing options...
bphlpt Posted June 25, 2013 Share Posted June 25, 2013 (edited) I know one of the differences is whether the cmd window remains visible while the commend is executing or merely flashes briefly, and I'm sorry but I don't remember which format does what. And, of course, we haven't mentioned about when, or whether, it is helpful to include "/wait" along with "start", but I know there is some misunderstanding/disagreement about that.Cheers and Regards Edited June 25, 2013 by bphlpt Link to comment Share on other sites More sharing options...
MHz Posted June 28, 2013 Share Posted June 28, 2013 What's the difference between "start xyz.exe" and "cmd xyz.exe"? Both seem to be doing the same thing, but I do know there are some major differences there.cmd xyz.exe fails as it should so I am unsure why no one sees the issue.The syntax is invalid.CMD expects a script to be passed to it unless you use /c or /k to invoke command line mode. Passing an executable to CMD as parameter without the previous switches is invalid to CMD so you should consider yourself lucky if it does work as it fails for me.If you can run a command from a script without using Start, then why add it. Note that Start is an internal command so it has a little overhead to add to the process. I personally do not care if you use it as I consider that it will not hurt too much. The use of CMD /C in a command file is invoking a separate instance of the command interpreter which is indeed an overhead of being another process, more memory and more differcult debugging.When to use Start?notepad.exe:: cmd notepad.exe REM stops here returning to a prompt so commented to run all scriptcmd /c notepad.exestart /wait "notepad.exe"www.msfn.org:: cmd www.msfn.org REM stops here returning to a prompt so commented to run all scriptcmd /c www.msfn.orgstart www.msfn.orgpauseThe most direct commands would be notepad.exe and start www.msfn.org.@bphlptExecutions in a command script are processed one after the other in sequence. This means each command is executed and the next command does not start until the previous command completes. If it did not do that by default then you would have a race condition happening and many scripts may fail with handling the return value of the previous command. If you use Start, then the process will continue without waiting so you can do other commands without concern to the Started process previously executed. If you use Start /Wait then the behavior of moving to the next execution is the same as the default of waiting in a script.To do a series of commands at an interactive command prompt like in the creation of a script is to first type the char ( , press the return key and then type each command line. When done adding commands then you can type the char ) to close the batch of commands and then it will execute automatically.@YzöwlNice to see the wise owl is still flying around. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now