Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any way to execute a Batch- or PowerShell-Script on shutdown using Windows 8 without disabling FastBoot?

I know you can add a script using "gpedit.msc", but I found that Windows 8 won't execute the shutdown script as long as FastBoot is enabled.

Having to deploy the script in an enterprise I don't wanna add shutdown command at the end of the script and tell some dozens people to shutdown the PC via the script.

share|improve this question
    
May you can do something along the lines of this user stackoverflow.com/questions/4782944/… who wanted to shutdown his Virtual machine on Windows shutdown. Note that that posts references others too. –  Jan Doggen Apr 17 '13 at 7:52
1  
Thank you for your quick answer, but i cant find any solution in this post. The problem is, that Windows won't execute any scripts i added to be executed on shutdown via "gpedit.msc". It works if i use "shutdown -s" or restart the pc –  an_heissel Apr 17 '13 at 8:13
    
Ah, I misread that post - he is also using a script. –  Jan Doggen Apr 17 '13 at 10:00
    
Ok I did some research again. It appears, that it is no longer possible with Win8 to execute a script on shutdown using gpedit. I was told, that a possible solution would be to create a scheduled task and link this to an event, that occurs on shutdown, yet i didn´t try this one –  an_heissel Apr 23 '13 at 11:47
    
Did that work? :) –  user89272 Dec 8 '13 at 0:09

2 Answers 2

Create a wmi event watcher on Win32_ComputerShutdownEvent, run it silently in the background from your logon script. It will wait all-day for the shutdown command. Upon event, send the "shutdown -a" and call your script.

share|improve this answer

I found this at KIOSKEA(work below) also check this out.

Open notepad and copy the code below:

Windows Registry Editor Version 5.00    

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts]    

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown]    

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup]    

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0]    
"GPO-ID"="LocalGPO"    
"SOM-ID"="Local"    
"FileSysPath"="C:\\Windows\\System32\\GroupPolicy\\Machine"    
"DisplayName"="Stratégie de groupe locale"    
"GPOName"="Stratégie de groupe locale"    

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0]    
"GPO-ID"="LocalGPO"    
"SOM-ID"="Local"    
"FileSysPath"="C:\\Windows\\System32\\GroupPolicy\\Machine"    
"DisplayName"="Stratégie de groupe locale"    
"GPOName"="Stratégie de groupe locale"    

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0\0]    
"Script"="C:\\script1.bat"    
"Parameters"=""    
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00    



Once you understand the code, you can adapt it to suit your needs by changing some of the variables.

C:\\script.bat represents the path to your script on the hard disk.
0 represents the number of the script in case you have several scripts to run.
Startup is the time of execution of the script (at startup is Startup and shutdown is Shutdown) 



It is possible to add multiple scripts:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0\0]    
"Script"="C:\\script1.bat"    
"Parameters"=""    
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00



It is also possible to specify parameters for the execution of this script by changing the Parameters field.

Finally, save this text file:

Go to File > Save
Give it a name ending with .reg
Select All files in the list box File Type
Save the file to the desired location and double click on this file
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.