ZTree.com  | ZEN  | About...  

 Index   Back

difference .. START "" %C1% %1 and START %C1% %1   [Q]

By: Ben Kent       
Date: Oct 15,2016 at 20:34
In Response to: difference .. START "" %C1% %1 and START %C1% %1 (Ryan)

> If Not Defined PUBLIC goto WinXP or If Defined PUBLIC goto Win10
> thanks for this line it was much more readable.
>
> my question about START.EXE
Start isn't start.exe, it's a built in command of cmd.exe, just like dir.



>
> SET C1="AAA.EXE"
>
> AA=
> START "" %C1% %1
That is the safe option, because the first quoted string is taken to be the title of the window.

>
> BB=
> START %C1% %1
If C1 is quoted, then it will be the title, and %1 will be opened using the associated application, i.e. it simplifies to START %1, the same as double clicking on the file in explorer.

>
> CC=
> %C1% %1
Would run C1 with %1 as a command line parameter and wait for it to complete.
Possibly depending on the OS and if the command was interactive or in cmd script, then it might run asynchronously, i.e. return control back to cmd.exe

>
> DD=
> CMD /C %C1% %1
I would expect that to be equivalent to CC, .



To summarize
1. Use START to launch a program and not wait for it to complete
2. The first quoted parameter of START is taken to be the title, so it is best to to add a defensive title, even is if just an empty string.
3. START can be used to launch executable's and files via there extensions, equivalent to double clicking in Explorer.
4. If START'ing and you want to pause until completion use the /wait switch.
5. Depending on OS, interactively running an executable might be synchronous or asynchronous, later OS's seem to go asynchronous, whereas running in a cmd script will always be synchronous (run and wait for completion).
6. there might be some differences between CC and DD in a cmd script, DD might follow the interactive rule.

Also, you need to define what you mean by "it doesn't work", some possibles
Application does not launch
The file get launched via file extension, instead of the exe with a parameter
It launched asynchronous when your expected synchronous
It launched synchronous when your expected asynchronous
...


in general for consistent behavior

launch and continue execution
start "" "path to exe" parameters

launch and wait for completion
start "" /wait "path to exe" parameters

to launch via file association
start "" "path to some file.ext"

if in a cmd script, then launch and wait for completion is best simplified to
"path to exe" parameters



It sounds like you need to learn a few defensive programing practices.
Also you shouldn't be using XP if connected to the internet, because it hasn't been patched for years.


Ben

1,028 views      
Thread locked
 

Messages in this Thread

 
96,637 Postings in 12,231 Threads, 350 registered users, 87 users online (2 registered, 85 guests)
Index | Admin contact |   Forum Time: Mar 28, 2024 - 7:51 pm UTC  |  Hits:62,378,052  (30,449 Today )
RSS Feed