How to run bat file before closing windows?

I am trying to run a BAT file just before shutting down Windows. I tried the method shown in the following question:

Script package execution on Windows shutdown

However, the file does not start.

I did not specify any parameters for the BAT file (see attached image below):

enter image description here

Should I add parameters to run it? I am on Windows 8.1.

+6
source share
5 answers

Very simple answer

Shortcuts that all make a shortcut that launches the batch file here, I clicked something batch code for you

Here you need to create a shortcut for the batch file

0
source

You probably missed gpupdate . the associated symptom of the script that is executed when the system is rebooted is vaguely related to the GP parameters used when the system reboots .

0
source

Go to the local group policy editor, then disable properties then add a script like you, but use the scripts tab, not the shell scripts. You do NOT need to run it as a powershell script unless it distracts things from powershell.

Hope this helps!

Example

0
source

Perhaps this does not work, because the script line of the Windows Shutdown Windows pop-up window in which you specified the location of the .bat file tells the computer to search for the location of the PowerShell file (.ps1) and not the .bat file, hence the error. Enter the same file location on the Scripts tab.

Alternatively, I can suggest creating a shortcut for the .bat file (for example, on your desktop), and when you want to shut down your computer (and start the .bat file), click on the shortcut that you created. After that, edit the .bat file and add this line of code to the end or where necessary:

c:\windows\system32\shutdown -s -f -t 00 

What does it mean?

  • Starts the shutdown process.
  • Displays a warning
  • Makes all running processes stop
  • Running immediately
0
source

your sequential file is followed by this shutdown sequence c:\windows\system32\shutdown -s -f -t 00

-1
source

Source: https://habr.com/ru/post/971133/


All Articles