If you want to make a Windows 8 shutdown script, you’ll have to work with the Group Policy Object Editor. Sounds a little more complicated than just copying a file? It probably is, but if you follow the steps below, you’ll have your shutdown script in no time.
First of all, it’s important to clearly define what we mean with shutdown script. Some people want to create a little command line script and then put an icon on their desktop or taskbar so that they can shut down their Windows 8 computer with one single click. This method is described in my Windows 8 shutdown article, but here in this article we’re on about something else.
Here, I’m talking about a script that contains one or more commands that you want your computer to carry out when you shut it down.
Let me try to make this a bit clearer with an example. Suppose you have a certain file or folder on your computer that is very important to you and you want to make a copy of it to an external hard drive every time you are finished working. Or you want to make a copy of your e-mails and contacts each time you power down your computer. You could then create a Windows 8 shutdown script that contains the copy command to copy the file or folder to your external hard drive and have that script executed automatically every time you shut down your computer. You can get this done with the Group Policy Object Editor in Windows 8.
For instance, take a look at the explorer window of my Windows 8 pc here:
Suppose I have a folder called “importantfolder” on my local drive c that I want to copy to the local drive e: each time I shut down the computer.
I would then create a text file, called “shutdownscript.bat” in my c:\importantfolder with the following command:
xcopy /e c:\importantfolder e:\importantfolder\
The Xcopy command is used to copy the contents of folders and the /e switch is used to make sure that all directories are also copied, also the empty ones.
This would then be what the "importantfolder" could look like:
And this could be the content of my shutdownscript.bet file:
I would run the script (shutdownscript.bat) in an elevated command prompt to test it for proper execution and as soon as I’m convinced that the script does what it’s supposed to do, I would use the Group Policy Object Editor in order to link it to the shutdown event. This is essential if I want my Windows 8 Shutdown Script to be executed each time the PC is shut down.
In order to run the Group Policy Object Editor, go to the Windows 8 start screen and type “mmc”. Then, right-click on the mmc.exe item that appears and select "Run as administrator", as shown here:
That will result in the Windows User Account Control to appear. Click "yes" in the User Account Control dialog.
This will result in the console window to open:
In the console, you can add the Group Policy Object Editor, by clicking the “Add/remove snap in” from the file menu as shown in the image below:
Then, select the Group Policy Object Editor and click the “Add” button like in the image below.
The Group Policy Wizard will ask you to select a Group Policy Object. You can simply click the finish button, like in the image below:
In the resulting window, navigate to local computer policy/computer configuration/windows settings/scripts (Startup/Shutdown).
The attentive reader will understand here that it is of course also possible to create a Windows 8 startup script, to carry out commands as you start your Windows 8 computer.
Double-click on “shutdown” to go to the shutdown properties window:
In the shutdown properties window, click the add button and then use the browse button to navigate to the script you want to run during shutdown.
Then, click the ok button and use the ok button once again in the shutdown properties window.
Now you can close the Group Policy Object Editor and shut down your computer to test your Windows 8 shutdown Script in order to make sure that it does what you intended it to do.
In this example I used a Windows 8 shutdown script to make a copy of a folder, but shutdown scripts can of course be used for any automated command that can be written in a script. This file copy example is obviously just to illustrate the mechanism of the shutdown script, but if you are looking for ways to make backup copies of your important data, there are of course better methods to accomplish that in the form of backup programs or even the built-in backup and recovery features of Windows 8.