I have searched for many weeks to solve my problem and can't find a good way of doing it that works on every machine I may need to use.
I know START command opens a new window to do the .exe, but I want to stay in the same window and run the .exe
(because I want my batch file to continue ONLY WHEN THE .EXE has finished running)
I have found that on some computers when I .exe it opens a new window and other computers is stays in the same window which makes me think my code is fine but there is a setting somewhere on the computers that is different.
Can you help? What are my options? The .exe I am running is NASTRAN which is an engineering solver that runs in command window.
Type "start [filename.exe]" into Command Prompt, replacing "filename" with the name of your selected file. Replace "[filename.exe]" with your program's name. This allows you to run your program from the file path.
Click Start, type cmd, and press Enter to open a command prompt window. In the Windows taskbar, right-click the command prompt window icon and select Command Prompt. A second command prompt window is opened.
If you're creating a batch file and want the MS-DOS window to remain open, add PAUSE to the end of your batch file. This prompts the user to Press any key. Until the user presses any key, the window remains open instead of closing automatically.
To wait for the command to terminate you should use the WAIT
flag:
start /WAIT c:/windows/system32/notepad.exe
You could start an application without creating a new window using the B
flag:
start /WAIT /B "c:/windows/system32/cmd.exe"
You should also try reading the help text for the start command:
start /?
You can use cmd /k example.exe
You probably have a different variant of the .exe on some machines which is called only there, and spawns a separate window, for reasons I cannot know. Search for the .exe file on all machines and compare.
Also, post your batch file code so we can exactly see how you start the .exe.
You could consider not using start at all. Simply start the executable directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With