djdiag
djdiag

Reputation: 51

Why is command start with parameter /wait not working properly?

OK this is racking my brain!!! I have one batch file that will start another batch file but every time I run say batch file all it does is open a command window with the title being where the batch file is located. Here is the batch file that's preforming the start /wait command:

::------------------------------ configure power settings ---------------------------

@echo off

start /wait "%~d0\SETUP_POSTOP\01 Configure Power Settings\always on.bat"

::------------------------------ programs and features ------------------------------

start /wait "%~d0\SETUP_POSTOP\02 Uninstall Unwanted Software\Programs and Features.bat"

The above batch file is supposed to run "always on" batch file but all it does is open another command window. Here is the "always on" batch file its trying to start:

@echo off

echo DO NOT CLOSE!!!

%windir%\system32\powercfg.exe /import "%~d0\SETUP_POSTOP\01 Configure Power Settings\alwayson.pow" 2f5ac084-2edf-444a-b1b9-8de872cf798e

%windir%\system32\powercfg.exe /setactive 2f5ac084-2edf-444a-b1b9-8de872cf798e

start /wait %windir%\System32\powercfg.cpl

exit

I've tried everything and all my research is pointing to a bug in the start command? I'm just up in arms with this one!

Upvotes: 4

Views: 4599

Answers (2)

JosefZ
JosefZ

Reputation: 30113

start "" /wait "%~d0\SETUP_POSTOP\01 Configure Power Settings\always on.bat"

The first double-quoted start command line parameter is treated as a window title.

Syntax: START "title" [/D path] [options] "command" [parameters]

Always include a title this can be a simple string ("My Script") or just a pair of empty quotes "".

According to the Microsoft documentation, the title is optional, but depending on the other options chosen you can have problems if it is omitted.

Upvotes: 2

MC ND
MC ND

Reputation: 70923

The start command will handle the first quoted argument as the title of the new window.

Try with

start /wait "" "%~d0\SETUP_POSTOP\01 Configure Power Settings\always on.bat"

Upvotes: 2

Related Questions