It is often desirable if the PC performs certain tasks , when the PC is started up or shut down , or when a Windows user logs on or off . These tasks can be controlled very easily via VBS scripts or small batch files and we want to show you how you can set them up accordingly.
Store scripts
The scripts that you have created must be stored in certain Windows system folders depending on the task. We have summarized these folders for you below.
Run script when computer starts:
C: WINDOWS System32 GroupPolicy Machine Scripts Startup
Run the script when the computer shuts down:
C: WINDOWS System32 GroupPolicy Machine Scripts Shutdown
Run script when a user logs on
C: WINDOWS System32 GroupPolicy User Scripts Logon
Run script when a user logs off
C: WINDOWS System32 GroupPolicy User Scripts Logoff
Your scripts must be stored in this directory in the form of .VBS or .BAT or .CMD. Since Windows 7 there is also the possibility to store PowerShell scripts here. Below you can see Windows Explorer in the ” GroupPolicy ” folder.
However, it is not enough to simply store the scripts to be executed in these directories . You have to define either global or local group policies, which will then execute the scripts when the required action is taken. These changes have to be made in the local group policy editor “gpedit.msc”, for example.
There are the settings for the ” Computer login scripts ” and ” User login scripts ” in the ” Computer configuration ” and ” User configuration ” areas under “Windows settings “.
Here you can add the script, which you have stored in the described Group Policy folders , via ” Add ” . There is a separate tab for the ” PowerShell scripts “, because the following options can still be set here.
- Not configured
- Run Windows PowerShell scripts first
- Run Windows PowerShell scripts last
You should definitely pay attention to these settings if you set several scripts and mix them in connection with Powershell scripts .
If you have set all settings correctly, your scripts or batch files will be executed correctly when you log in, log out, start up or shutdown the computer .
If you are looking for more information about scripts, you may be interested in the following articles.
– Windows fix 10 Update problems with a script
– E-mails in the logon script
– software inventory via VBS script
– Per login script network printing and delete the Printer Driver
– find network problems – only log ping dropouts – Pingtest.bat
– PowerShell scripts run on Windows 7