If you have one or more programs that you use each
day, or that you use as soon as Windows XP starts, you can save yourself
the hassle of launching these programs manually by getting Windows XP
to do it for you automatically at startup. Similarly, you can also get
Windows XP to automatically launch scripts or batch files at startup.
You could set up a program or script for automatic startup launch using
the Startup folder, the Registry, and the Group Policy snap-in.
Using the Startup Folder
The Startup folder is a
regular file folder, but it has a special place in Windows XP: You can
get a program or script to run automatically at startup by adding a
shortcut for that item to the Startup folder. Note that the Startup folder appears twice in the Windows XP interface:
Via the Start menu (click Start, All Programs, Startup). Via Windows Explorer as a subfolder in %SystemDrive%:\Documents and Settings. Actually, there are three different subfolders you can work with: \user\Start Menu\Programs\Startup | Here, user
is the name of a user defined on the system. A shortcut placed in this
folder will run automatically when this user logs on to the system. | \All Users\Start Menu\Programs\Startup | A shortcut placed in this folder will run automatically when any user logs on to the system. | \Default User\Start Menu\Programs\Startup | A
shortcut placed in this folder will be automatically copied to a user’s
Startup folder when you create a new user account. The Default User
subfolder is hidden by default. To display it, select Tools, Folder
Options in Windows Explorer, display the View tab, and then activate the
Show Hidden Files and Folders option. |
Note that only
users with Administrator-level rights can access all three of these
subfolders. Users with lesser privileges can work only with their own
Startup folder. They can see the All Users version of the Startup
folder, but Windows XP prevents them from adding files to it.
Tip
You can prevent the
Startup items from running by holding down the Shift key while Windows
XP loads (hold down Shift after logging on). Using the Registry
The
Startup folder method has two drawbacks: Users can easily delete
shortcuts from their own Startup folders, and users can bypass Startup
items by holding down the Shift key while Windows XP loads. To avoid
both problems, you can use the Registry Editor to define your startup
items. Assuming that you’re logged in as the user you want to work with,
the Registry offers two keys:
HKCU\Software\Microsoft\Windows\CurrentVersion\Run | The values in this key run automatically each time the user logs on. | HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce | The
values in this key run only the next time the user logs on, and are
then deleted from the key. (This key might not be present in your
Registry. In that case, you need to add this key yourself.) |
If you want an item to run at startup no matter who logs on, use the following keys:
HKLM\Software\Microsoft\Windows\CurrentVersion\Run | The values in this key run automatically each time any user logs on. | HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce | The
values in this key run only the next time any user logs on, and are
then deleted from the key. Don’t confuse this key with the RunOnceEx key. RunOnceEx is an extended version of RunOnce
that’s used by developers to create more robust startup items that
include features such as error handling and improved performance. |
To create a startup
item, add a string value to the appropriate key, give it whatever name
you like, and then set its value to the full pathname of the executable
file or script file that you want to launch at startup.
Caution
Placing the same startup item in both the HKCU and the HKLM hives will result in that item being started twice: once during the initial boot and again at logon.
Tip
If the program is in the %SystemRoot%
folder, you can get away with entering only the name of the executable
file. Also, if the program you want to run at startup is capable of
running in the background, you can load it in this mode by appending /background after the pathname. Using Group Policies
If you prefer not to edit
the Registry directly, or if you want to place a GUI between you and the
Registry, XP Professional’s Group Policy snap-in can help. Note, however, that Group Policy doesn’t work directly with the Run keys in the HKLM and HKCU hives. Instead, these are considered to be legacy keys, meaning that they’re mostly used by older programs. The new keys (new as of Windows 2000, that is) are the following:
HKLM\Software\Microsoft\Windows\CurrentVersion\policies\Explorer\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\ Policies\Explorer\Run
These keys do not
appear in Windows XP by default. You see them only after you specify
startup programs in the Group Policy editor, as discussed in the next
section. Alternatively, you can add these keys yourself using the
Registry Editor.
Note
The startup items run in the following order:
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKLM\Software\Microsoft\Windows\CurrentVersion\policies\Explorer\Run
HKLM\Software\Microsoft\Windows\CurrentVersion\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce
Startup folder (all users)
Startup folder (current user)
Adding Programs to the Run Keys
As mentioned, you can
either add values to these keys via the Registry Editor, or you can use
the Group Policy snap-in. To open the Group Policy window in Windows XP
Professional, select Start, Run, type gpedit.msc, and then click OK. In the Group Policy window, you have two choices:
To work
with startup programs for all users, select Computer Configuration,
Administrative Templates, System, Logon. The items here will affect the
Registry keys in the HKLM (all users) Registry hive. To
work with startup programs for the current user, select User
Configuration, Administrative Templates, System, Logon. The items here
will affect the Registry keys in the HKCU (current user) hive.
Either way you’ll see at least the following three items:
Run These Programs at User Logon | Use this item to add or remove startup programs using the \Policies\Explorer\Run
keys in the Registry. To add a program, double-click the item, select
the Enabled option, and then click Show. In the Show Contents dialog
box, click Add, enter the full pathname of the program or script you want to run at startup, and then click OK. | Do Not Process the Run Once List | Use this item to toggle whether Windows XP processes the RunOnce
Registry keys (which I discussed in the previous section). Double-click
this item and then activate the Enabled option to put this policy into
effect; that is, programs listed in the RunOnce key are not launched at startup. | Do Not Process the Legacy Run List | Use this item to toggle whether Windows XP processes the legacy Run
keys. Double-click this item and then activate the Enabled option to
put this policy into effect; that is, programs listed in the legacy Run
key are not launched at startup. |
Specifying Startup and Logon Scripts
You also can use the Group Policy snap-in to specify script files to run at startup. You can specify script files at two places:
Computer
Configuration, Windows Settings, Scripts (Startup/Shutdown)—Use the
Startup item to specify one or more script files to run each time the
computer starts (and before the user logs on). Note that if you specify
two or more scripts, Windows XP runs them synchronously. That is,
Windows XP runs the first script, waits for it to finish, runs the
second script, waits for it to finish, and so on. User
Configuration, Windows Settings, Scripts (Logon/Logoff)—Use the Logon
item to specify one or more script files to run each time any user logs
on. Logon scripts are run asynchronously.
Finally, note that
Windows XP has policies dictating how these scripts run. For example,
you can see the startup script policies by selecting Computer
Configuration, Administrative Templates, System, Scripts. There are
three items that affect startup scripts:
Run Logon Scripts Synchronously | If you enable this item, Windows XP runs the logon scripts one at a time. | Run Startup Scripts Asynchronously | If you enable this item, Windows XP runs the startup scripts at the same time. | Run Startup Scripts Visible | If you enable this item, Windows XP makes the startup script commands visible to the user in a command window. |
For logon scripts, a
similar set of policies appears in the User Configuration,
Administrative Templates, System, Scripts section.
Caution
Logon
scripts are supposed to execute before the Windows XP interface is
displayed to the user. However, Windows XP’s new Fast Logon Optimization
can interfere with that by displaying the interface before all the
scripts are done. The Fast Logon Optimization feature runs both the
computer logon scripts and the user logon scripts asynchronously, which
greatly speeds up the logon time since no script has to wait for another
to finish.
To
prevent this, select Computer Configuration, Administrative Templates,
System, Logon and enable the Always Wait for the Network at Computer
Startup and Logon setting. Using the Scheduled Tasks Folder
Yet another way to
set up a program or script to run at startup is to use the Scheduled
Tasks folder (select Start, All Programs, Accessories, System Tools,
Scheduled Tasks, or use Windows Explorer to display the %SystemRoot%\Tasks folder). When you create a new task, two of the startup options you’ll see are
When My Computer Starts | Choose
this option to run the program when your computer boots, no matter
which user logs in. Note that only someone logged in under the
Administrator account can use this option. The tasks will run otherwise,
but they won’t display. | When I Log On | Choose
this option to run the program only when you log on to Windows XP. This
is the option to use for accounts other than Administrator. |
Caution
Note that a bug in
Windows XP prevents it from running a scheduled task if your user
account doesn’t have a password. You need to assign a password to your
account and then add the password to the scheduled task. Note that this
bug is still not fixed in Service Pack 2.
|