Reputation: 71
I am trying to run a BAT file immediately before Windows shutdown. I've tried the method shown in the question below:
Executing a batch script on Windows shutdown
However, the file does not run.
I did not specify any parameters for the BAT file (see attached image below):
Should I add parameters in order for it to run? I am on Windows 8.1.
Upvotes: 7
Views: 14126
Reputation: 510
This possibly isn't working because the script line of the 'Windows Shutdown Properties' pop-up window where you entered the location of the .bat file, tells the computer to look for the location of a PowerShell file (.ps1), not a .bat file, hence the error. Enter the same file location on the 'Scripts' tab.
Alternatively, what I can suggest doing is creating a shortcut to the .bat file (for example on your desktop) and a when you want to shutdown your computer (and run the .bat file) click on the shortcut you created. After doing this, edit the .bat file and add this line of code to the end or where needed:
c:\windows\system32\shutdown -s -f -t 00
What this does it is
Upvotes: 1
Reputation: 183
Navigate to the Local Group Policy Editor, then the shutdown properties then add a script like you did, but use the scripts tab, not powershell scripts. You do NOT need to run it as a powershell script unless it pulls things from powershell specifically.
Hope this helps!
Upvotes: 3
Reputation: 152
it's likely that you missed gpupdate. the related symptom of script executing at system reboot is vaguely related to the GP settings applied on reboot by system itself.
Upvotes: 0
Reputation: 467
Very easy answer
Shortcuts that's all make a shortcut that makes a batch file run here i snapped somethingthe code of batch file for you
Here you have to make a shortcut for a batch file
Upvotes: 1
Reputation: 3
have your batch file be followed by this shutdown sequence c:\windows\system32\shutdown -s -f -t 00
Upvotes: -1