Answered by:
run Shutdown.cmd instead of shutdown.exe, Windows 10

Question
-
I could not find a reasonable forum for this question. Please direct me?
I run virtual machines on a Windows 10 PC. To avoid shutting down the host PC while VMs are running I have removed Shut Down, Restart, and Log Off from the Start menu. I use shutdown.exe from Run... with appropriate switches, like this:
shutdown -s -t 10
shutdown -r -t 10
Please note that I type "shutdown", not "shutdown.exe".
I would like to have "shutdown" run shutdown.cmd, a batch file that I make which would hibernate all my VMs first, then run shutdown.exe. I vaguely remember something like this was possible back in ME days, is it possible now? I have tried putting shutdown.cmd in c:\windows, and the folders under Windows where shutdown.exe resides (system32 and syswow64). I have moved .CMD in front of .EXE in the PATH environment variable. But "shutdown" always calls "shutdown.exe", not the .cmd. I have tried renaming shutdown.exe to something else and was blocked by Windows. I tried taking ownership of shutdown.exe and was again blocked.
I have tried using the Group Policy shutdown scripts, but the VMs are killed off long before those scripts start running.
I know I can type "shutdown.cmd" instead of just "shutdown", but I might forget one day. Is it possible to get Windows to run the .cmd first before it runs an .exe?
Friday, September 16, 2016 3:17 PM
Answers
-
I'd try them over here.
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.- Proposed as answer by Mike Laughlin Friday, September 16, 2016 4:17 PM
- Marked as answer by Just Karl Monday, September 26, 2016 7:44 PM
Friday, September 16, 2016 4:10 PM
All replies
-
Didn't test it with Windows 10 but the order in which the command is identified is defined in the PATHEXT environment variable. Standard value vor this is ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC". If you move the .cmd before the .exe it should take your shutdown.cmd instead of the shutdown.exe.
- Marked as answer by RnGScottgus1 Friday, September 16, 2016 3:46 PM
- Unmarked as answer by RnGScottgus1 Friday, September 16, 2016 3:46 PM
Friday, September 16, 2016 3:27 PM -
Thanks, Olaf! I did try that too, and rebooted as well just in case.
My PATHEXT is .COM;.BAT;.CMD;.EXE;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
CMD before EXE, but "shutdown" in the Run... box is still running "shutdown.exe", not "shutdown.cmd", which resides in the same system32 folder.
I did find that running "shutdown" in a command window does run my .cmd, but running from "Run..." does not. Strange...
Friday, September 16, 2016 3:52 PM -
I'd try them over here.
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.- Proposed as answer by Mike Laughlin Friday, September 16, 2016 4:17 PM
- Marked as answer by Just Karl Monday, September 26, 2016 7:44 PM
Friday, September 16, 2016 4:10 PM -
I will do that, thanks!Friday, September 16, 2016 4:27 PM
-
You're welcome.
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.Friday, September 16, 2016 4:41 PM -
Friday, September 16, 2016 4:42 PM
-
Good day RnGScottgus1,
Please close this thread :-)
This forum meant to give you the instruction of "where to ask the question". Now that you found the right forums, this thread can be closed here. The answers to the original question should come there in the specific forums for the topic you need.
Ronen Ariely
[Personal Site] [Blog] [Facebook] [Linkedin]Saturday, September 17, 2016 6:26 AM