Thursday, August 19, 2010


How To Make A StartUp Script In Windows | Using Startup Scripts

The process of making a startup script—a script that is executed automatically when Windows starts—is quite simple. Essentially, you create an ordinary PowerShell Script, batch file, or any other type of script and then take steps to have it executed when Windows starts. There are a few different ways to do this:

Use the Startup folder
Put a shortcut to the script in your Startup folder (usually C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup). 

This is by far the easiest to implement, but also the most fragile, because it’s equally easy to disable. 

If there is more than one user account on a computer, and you want the script to be executed regardless of the currently logged-in user, you can use the “All Users” Startup folder (usually C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\Startup) instead. 

Use the Registry
Open the Registry Editor and expand the branches to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

Select New and then String Value from the Edit menu, and type startup script. Double-click the new Startup Script value, type the name of your script (e.g., c:\scripts\myscript.vbs), and click OK. Although it’s a bit harder to implement, this setup is a little more buried, and thus more difficult for unwitting users to mess up than items placed in the Startup folder.

Many viruses and spyware install themselves in this Registry key precisely because it’s so transparent.for tips on how to remove malware from this key.

Likewise, you can implement this solution for all users rather than just the current user by adding the Registry value to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run instead.

Use the Group Policy Editor
This is probably the coolest solution, as it gives you the most control over precisely when the script is run, and it’s the only way to facilitate a shutdown or logoff script as well. Open the Group Policy Editor (gpedit.msc), and expand the branches to Computer Configuration\Windows Settings\Scripts Startup/Shutdown). 
Double-click the Startup entry on the right side, and then click Add. Click Browse to locate a script file, and click OK when you’re done. The script will be run every time you start your computer, but before the logon or Welcome screen appears (and before scripts specified in the Registry or Start menu are ever run).

Likewise, double-click the Shutdown entry to specify a script to be run every time your computer shuts down. Now, there’s a similar setting called Scripts (Logon/Logoff), located in the User Configuration branch. Like everything in the User Configuration branch, these settings apply only to the currently logged-on user (as opposed to all users). If you specify your startup script here (under Logon), instead of under Computer Configuration, the script will run after you log in. And, of course, a script specified under Logoff will be run when you log off, whether or not you actually shut down the computer. 

StartUp Script
A startup script can contain a list of programs that you want to run in a specific order when Windows starts, such as connecting to the Internet and then checking your email. (Neither Explorer’s Startup folder nor the Registry allow you to choose the order in which programs are run.) But there are other, less apparent uses for a startup script, such as for security or remote administration. 

For example, say you’ve discovered malware that has infected some or all of the computers on a network. By writing a script that eliminates the malware by deleting key files or running a removal utility and setting it up as a startup script, you can effectively eliminate it from each computer.
But with scripts, you can take it even further: utilize a single script stored on a single computer that is run, over the network, on all computers. This way, you can make changes to the script once and have those changes propagated to all computers effortlessly. So, if you place the script Startup.vbs on a machine called Server in a folder called C:\scripts (drive C: would be shared as “C”), then each client machine should be configured to automatically execute \\server\c\scripts\startup.vbs (using one of the above mentioned methods). 
The beauty of this is that when you don’t want the script to do anything, you can simply leave it intact yet empty. If you find that you need to, say, make a Registry change or copy a group of files onto each computer, just type the appropriate commands into the script and turn on (or reboot) all the client computers. 

This can turn some administration tasks into very short work.


About bench3 -

Haja Peer Mohamed H, Software Engineer by profession, Author, Founder and CEO of "bench3" you can connect with me on Twitter , Facebook and also onGoogle+

Subscribe to this Blog via Email :