Execute a script a startup and shutdown

Last update on July 30, 2009 08:32 AM by jak58
Published by jak58

Execute a script a startup and shutdown



The trick works Windows XP, Vista and 7, but the method varies depending on your edition of Windows.

For professional or full editions


Start the policy editor of the local group: Start Menu> Run> Type gpedit.msc
Under Vista, you can type the command in the search bar of the start menu or by shortcut Windows key + R
Go to Computer Configuration> Windows Settings> Scripts (Startup/Shutdown)
Depending on what you want, double click on Start or Stop system
Click Add> Browse and select the script you want to add.

For all editions


Note that implies midification of the Registry, it is recommended to make backup before proceeding

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


Note that what is underlined is a variable and that you can adapt it to your needs.
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. Just increment the number.
Startup is the time of execution of the script (at startup is Startup and shutdown is Shutdown)


Add as many times as you want, always adapting to your needs, the example below if you want 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.
Best answers for « Execute a script a startup and shutdown » in :
Execute a script a startup and shutdown Show Execute a script a startup and shutdown The trick works Windows XP, Vista and 7, but the method varies depending on your edition of Windows. For professional or full editions Start the policy editor of the local group: Start Menu> Run> Type...
Start/stop a service using command line ShowStart/stop a service using command line The netsh tool (netsh.exe) can automate the startup or shutdown of a service through the following command line: To start a service: Net start name_of_service To stop a service:...
Unable to run executable files (. Exe) ShowUnable to run executable files (. Exe) First Solution Second solution My programs are launching no more It may happen that only executable files aren’t eager open properly: either you have the dialog box "Open With", it opens with...
[Windows] How to disable scan disk at Start up Show[Windows] How to disable scan disk at Start up It happened almost all the time when windows are improperly shut down after a troubleshoot that scandisk will run on the next reboot to check the contents of the hard disk. (see below...
Download Vista Shutdown Timer ShowWhen you download a spacious file or when an installation or a transfer hesitates to end! Not how to be obliged to wait for the end of task? Vista Shut Down Timer is a program allowing to define the hour of stopping or the conditions of stopping of...
Operating Systems - Windows - Tips and Tricks - Using Windows ShowRestart Windows 9x without rebooting When you go to restart Windows, you click on Start, Shut Down, and then Restart. To restart Windows wthout having to restart the computer, simply hold while clicking on OK. A shortcut for shutting down...
Execution phase of a project ShowExecution phase Preparation Before beginning the execution of the work, it is necessary to take the time to break the project down into tasks in order to plan the performance of these tasks and determine what resources need to be mobilized....