Many programs set themselves to run at startup, or run something once in Windows 2000. This is not that difficult to do, and simply involves adding a Registry entry.

If you want to add a program that runs at startup for every user in Windows 2000, navigate to the following key:

HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRun

and add a new String value. The name of the key is arbitrary and is simply used for identification, but the value of the string must be the full drive and pathname to the executable or batch file you want to run. If your program includes switches or options, you must pass them like this (note the use of the quotes):

"<drive><path><program name>" /switch1 /option2

If you want keys in the Run section to execute in a certain order, your best bet is to put them all into a batch file in the order you want them to run in, and then execute the batch file from the key.

To add programs that run only once when you start Windows 2000, add keys in the same fashion to this subkey:

HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionRunOnce

Note: All RunOnce keys expire after they conclude their run, whether or not they exited successfully.

If you want to execute Run or RunOnce for a specific user, you need to modify the key:

HKEY_USERS<userID>SoftwareMicrosoftWindowsCurrentVersionRun

    Requires Free Membership to View


HKEY_USERS<userID>SoftwareMicrosoftWindowsCurrentVersionRunOnce

where <userID> is the ID number for the user in question. If you want to figure out what user belongs to what ID, look in the key HKEY_USERS<userid>Volatile Environment for the HOMEPATH key, which usually has the username listed in it.

If you want to temporarily disable a Run key, you can do one of two things: rename the path to the executable to something bogus, or you can copy it to another subkey named Run- or something similar. I usually use the first approach and just rename the extension of the file (from .EXE to .EXE.BAK), since it's relatively easy to undo in this fashion.

Note: You must to have appropriate permissions to add a Registry key (i.e., Administrator privileges, usually). Also, if the policy for your system is set not to use Run or RunOnce, these keys won't be executed.

If you want to use a batch file to add a key manually, you can create the key, export it to a file with the extension .REG, and then add it in again by using the REGEDIT command:

REGEDIT /S <importfile>

where <importfile> is the path and name of the .REG file to import. The /S (silent) switch suppresses any messages to the console. (If you're really clever, you can even use this within Run or RunOnce to recursively add entries to Run or RunOnce, where one batch file calls another and so on, but use this with caution; don't create an endless loop.)


Serdar Yegulalp is the editor of the Windows 2000 Power Users Newsletter.


This was first published in September 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.