Latest tutorial: Making a Movieclip face another Movieclip or point on the stage | Ask Tutorial5!
 

How to: Add startup and shutdown scripts in Windows

(28 votes)
Written by Mihai Dobos   
There are some features of Microsoft Windows that can come very handy from time to time if you know how to use them. Startup and shutdown scripts feature is one of that.

Firstly, you should know what scripts are all about. A script is a set of commands that your system can run in order to automate tasks.

If you'd like to run 2 programs and 20 commands every day for example, you don't have to do this by hand. Simply use batch files or Visual Basic scripting and they're done by a click of the mouse.

*NOTE: Learn some scripting basics if you are a novice; scripts that are not corectly written can block the computer, the windows startup process or the windows shutdown process.

For example, here is how you can delete all files in a folder (let's say c:\temporary\) with a script:

1. Create a file called script.bat (Right click - New -> Text document and open it with notepad; now click File - Save as and write it's name and extension - .bat with the option Save as: All files)

2. Add the line bellow and save the file.

del /q c:\temporary\*

By running this batch file you will delete all files in that folder (/q forces delete without confirmation).

01-script.jpg

This is a very simple script; the posibilities are endless and you should learn to use visual basic scripting if you want to build some proffesional work.

Now if you want to integrate any kind of script to automatically run when Windows starts or shuts down (user logon/logoff), you must follow these steps:

1. Click Start - Run and type mmc

02-run mmc.jpg

(note that you must be logged in with an administrator account for this)

2. On the Management console that starts, click File -> Add/Remove Snap-in.

3. On the window that opens, search for Group Policy Object editor on the left panel, click Add and in the properties window that pops out leave the settings that are selected (Local computer) and click ok. The result should be like in the picture bellow

03-add snapins in mmc.jpg




Click "OK"

4. Navigate through the left panel by opening each branch like this: Console Root -> Computer configuration -> Windows Settings -> Scripts (Startup/shutdown)

04-scripts startup - shutdown.jpg

5. Open the properties window for Startup or Shutdown as you desire from the right panel; on the window that pops out add, edit or remove scripts that you want.

05-script selector.jpg


This works on Windows 2000/2003/XP and Vista. Hope you found this useful.



Subscribe now via RSS feed and get all the new tutorials

written by Frank , February 12, 2008

Interesting concept, but it doesn't execute the script at shutdown.
written by vikram , February 19, 2008

thank u lot
pls send some more interactivity on writing batch file
written by alvin , March 13, 2008

how to shutdown a computer using time delay ?
written by Mihai Dobos , March 13, 2008

Hello Alvin


Open a command prompt (Start menu - Run - cmd) and type "shutdown /?". The shutdown command lets you shutdown, restart, log off, etc your PC after a given period of time.

written by vinitha , April 04, 2008

how to shutdown a client in a network
written by Kabeer Siddiqui , April 27, 2008

script for shutdown the multiple computers ?
written by Rudi ludick , May 09, 2008

Hi

How can i shutdown a remote pc that is not part of a domain but is in a workgroup? If i use the shutdown command i get access denied.Could some one please help with this?
written by Alex_number12345 , September 20, 2008

>>Now if you want to integrate any kind of script to automatically run when Windows starts or shuts down (user logon/logoff), you must follow these steps:
Startup/shutdown happens when you turn on/off your computer.
Login/logoff happens when you are logging in/off to user account.
You need to know that this are totally diffrent things.
Startup/Shutdown happens even user is not logged in (Welcome screen is used).
Login/logoff applies ONLY for selected user.
written by Jason IT Guy , September 30, 2008

How do i execute this command prior to the windows screen that says running script.

Basically i want to execute my script as SOON as i click OK to shutdown/restart regardless of what is open in the background.
written by Rymnd , October 06, 2008

Nice.... instead of typing mmc try typing gpedit.msc. Brings you directly to the desired policy.
written by mike pulli , December 21, 2008

I want to enable auto logon and have the computer open to my company's intranet page. This computer should act as a kiosk and not allow users to do anything but open links on the intranet page.
written by WVPNEWS , December 23, 2008

I use these GPO logoff script to write performance counter data to a database. But it seems that the performance counters are already cleared when my script executes -> I write output also to a local file and the counters don't exist anymore -> it's not a security issue with the database.

Is there a way to get the performance counter data at logoff time before the counters are cleared ?
written by Musoft , December 23, 2008

I am looking for a Windows shutdown script. This script must prevent Windows shutting down when ntbackup.exe is running.
written by sukanta , January 17, 2009

Would you please to give me a script to startup and shutdown automatically in windows server 2003?. I want it starts every 07.00 am and shutdown at o5.00 pm automatically. Please..
written by Thanh Son , March 10, 2009

thanks a lot. this is very useful indeed.
written by Tim A , March 29, 2009

The group policy snap-in is missing in Home, and Home Premium versions of Vista. Is there a way to hook a shutdown script into a Home version?
written by Dsmith , April 02, 2009

I want a confirmation box to display at startup that reads the user login and writes their login to a file. The message box says a few words and then prompts them to click on Okay or Cancel. Okay writes the username to the file. Cancel takes them back to the login screen.
written by Jegan , April 09, 2009

Thanks a lot, i was looking exactly the same.
written by DebasishBhat , July 09, 2009

i am using windows server 2003.I want tomcat icon is startup.So i add the same in run key.But after restating the system this icon is not showing.I am not using administrator login.Without admin login can i able to see tomcat icon in startup.Kindly help.I am frustrated.
written by Dan W , July 14, 2009

I tried doing this on windows vista home premium in an admin account, but it gave me an error message when I tried to add the snap-in. It basically said I can't do it and should use the control panel. Has anyone else encountered this? Do I need Ultimate to make this work?
written by muddasir , July 24, 2009

create a batch file first then follow the above mentioned steps and accordingly locate the batch file.
written by muddasir , July 24, 2009

create a batch file first then follow the above mentioned steps and accordingly locate the batch file in startup script.
written by Mow Row , August 24, 2009

what is the script for enabling certain programs only?

Thanks!
Row
written by mtsam , September 13, 2009

I am trying to use a bat file to shutdown a remote machine through shutdown script but not executing, same file is working in double click
written by mtsam , September 13, 2009

I am trying to use a bat file to shutdown a remote machine through shutdown script but not executing, same file is working in double click
written by mtsam , September 13, 2009

I am trying to use a bat file to shutdown a remote machine through shutdown script but not executing, same file is working in double click
written by eu , September 23, 2009

merci fain ! fix ce cautam! :)
written by topcathunter , November 20, 2009

I have domain admins on our work network and can use the 'shutdown /i' GUI to remotely shutdown/restart/logoff PCs. Is there a way to allow the user to Cancel the restart/shutdown command, say twice, then force a reboot on the third cancel? Some of our machines are in clinical areas in the hospital and I want to allow the user to postpone the shutdown for say a specified time. Any help appreciated.
written by r00t , November 30, 2009

I have most of my batch file down..but I want to add a few more things and I have a few questions.

Is it possible when cmd makes a text file to email it to me without the user doing anything?

Also, I want to make an authentication method, so when windows starts so does my batch file asking for a un and pw. I want to make it so if the correct username and password isnt typed windows is shut down.


any help?
written by Ong van Bau , December 22, 2009

What Am I must type in the Run box to open Start up for Windows XP?
written by Greg Walker , January 14, 2010

On the original posting, can the delete command function on a networked drive? i.e. should this work?

del /Q Z:Recycle BinGW-MdocsMailbox

or even

del Q/ serv3gregwRecycle BinGW-MdocsMailbox

written by laxman , January 19, 2010

Would you please to give me a script to startup and shutdown automatically in windows server 2003?. I want it starts every 07.00 am and shutdown at o5.00 pm automatically. Please..mail me
written by laxman , January 19, 2010

how to disallowed use to internet to user or computers in workgroup and domains
written by laxman , January 19, 2010

script for shutdown the multiple computers ?
written by laxman , January 19, 2010

how to shutdown a client in a network
written by B0ries , January 28, 2010

The group policy doesn't work in Windows XP home, Vista home (premium). For XP Home, you can 'upgrade' it to pro, with the boot-up cd-rom. Just search, google.
written by nhakrulz , October 12, 2011

this didnt work for me as well i am trying to run a server bat file which is listening on certain port for data.. i want that .bat file to be executed as soon as the user log's in
written by VV , September 25, 2012

Please send the Scripts..

Do you need more help? Ask now!
 

busy
Last Updated ( Thursday, 13 March 2008 )