Launching programs is one of
the most fundamental operating system tasks, so it isn’t surprising that
Windows Vista offers an impressive number of ways to go about this:
Use the Start menu—
Click the Start button to open the Start menu. If you’ve used the
program a lot, it should appear in the list of most frequently used
(MFU) applications, so click its icon. Otherwise, click All Programs and
then open the menus until you see the program icon, and then click the
icon.
Double-click the executable file— Use Windows Explorer to find the application’s executable file, and then double-click that file.
Double-click a shortcut— If a shortcut points to a program’s executable file, double-clicking the shortcut will launch the program.
Double-click a document—
If you can use the application to create documents, double-clicking one
of those documents should launch the program and load the document
automatically. (If the document was one of the last 15 that you used,
select Start, My Recent Documents, and then click the document in the
submenu that appears.)
Use the Open With command—
If double-clicking a document opens the file in the wrong application,
right-click the file and then click Open With.
Insert a CD or DVD disc—
Most CDs and DVDs support Windows Vista’s AutoPlay feature that
automatically starts a default program when the disc is inserted. The
program that launches is determined by the contents of the Autorun.inf file in the disc’s root folder. Open the file in Notepad and look for the open value in the [AutoRun] section.
Use the Run dialog box— Select
Start, All Program, Accessories, Run (or press Windows Logo+R) to
display the Run dialog box. Use the Open text box to specify the
application (click OK when you’re done):
Tip
One of the most annoying interface changes in
Windows Vista is the burying of the Run command in the Accessories menu.
If you use Run frequently, you might want to restore it to its rightful
place on the main Start menu. Here’s how: right-click the Start button,
click Properties, and then click Customize. In the list of Start menu
item, scroll down to the Run Command check box and activate it. Click OK
to make it so.
If the application resides within the %SystemRoot% or %SystemRoot%\System32 folder, within a folder listed as part of the PATH
environment variable, or if it has an application-specific path in the
Registry , just type the primary
name of the executable file.
For all other applications, enter the full pathname (drive, folder, and filename) for the executable file.
You
can also enter the full pathname of a document. If you want to open the
document using a program other than the one associated with the
document’s file type, precede the document pathname with the
application’s pathname (separate the two paths with a space).
Use the Task Scheduler—
You can use the Task Scheduler to run programs automatically at a given
date and time, or on a regular schedule. Select Start, Control Panel,
System and Maintenance, Scheduled Automated and Periodic Tasks.
In addition to these methods, you can also
control AutoRun behavior, set up the program to run automatically at
startup, use the Run As Administrator command, and create your own
application-specific paths. I discuss these methods in detail in the
next three sections.
Controlling AutoRun Behavior for Programs
If you prefer to have some control over what
happens when you insert a program’s CD or DVD, you can modify the
default AutoRun behavior for programs. Follow these steps:
1. | Click Start, Default Programs to display the Default Programs window.
|
2. | Click Change AutoPlay Settings. Windows Vista displays the AutoPlay window, shown in Figure 1.
|
3. | Use the Software and Games list to click the AutoPlay behavior you prefer.
|
4. | Click Save.
|
Launching Applications and Scripts at Startup
If
you have one or more programs that you use each day, or that you use as
soon as Windows Vista starts, you can save yourself the hassle of
launching these programs manually by getting Windows Vista to do it for
you automatically at startup. Similarly, you can also get Windows Vista
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 Vista: 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 Vista interface:
Via the Start menu (click Start, All Programs, Startup)
Via Windows Explorer as the following subfolder:
\user\AppData\Roaming\Microsoft\Windows\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.
Tip
You can prevent the Startup items from running
by holding down the Shift key while Windows Vista loads (hold down the
Shift key 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 Vista 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. In addition, 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,
Vista Pro’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 Vista 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\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 Vista 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 Vista processes the RunOnce
Registry keys (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 Vista 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
Vista runs them synchronously. That is, Windows Vista 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 Vista has policies
dictating how these scripts run. For example, you can see the startup
script policies by selecting Computer Configuration, Administrative
Templates, System, Scripts. Three items affect startup scripts:
Run Logon Scripts Synchronously— If you enable this item, Windows Vista will run the logon scripts one at a time.
Run Startup Scripts Asynchronously— If you enable this item, Windows Vista will run the startup scripts at the same time.
Run Startup Scripts Visible— If you enable this item, Windows Vista will make 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 Vista interface is displayed to the user. However, Windows
Vista’s improved logon can interfere with that by displaying the
interface before all the scripts are done. Windows Vista runs both the
computer logon scripts and the user logon scripts asynchronously, which
greatly speeds up the logon time because 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 Task Scheduler
Yet another way to set up a program or script to run at startup is to use the Task Scheduler. Here are the steps to follow:
1. | Select Start, Control Panel, System and Maintenance, Scheduled Automated and Periodic Tasks.
|
2. | Click Create Task.
|
3. | In the General tab, use the Name text box to enter a name for the task.
|
4. | In the Triggers tab, click New to display the New Trigger dialog box.
|
5. | In the Begin the Task list, click one of the following and then click OK:
At Log On— Choose this option to run the program only when you log on to Windows Vista.
At Startup— Choose this option to run the program when your computer boots, no matter which user logs in.
|
6. | In the Actions tab, click New to display the New Action dialog box.
|
7. | In the Action list, select Start a Program.
|
8. | Use the Program/Script text box to enter the path of the program or script.
|
9. | Click OK.
|
10. | Click OK.
|
Running a Program with the Administrator Account
Windows
Vista’s User Account Control feature requires credentials from you when
you attempt to run certain programs. This is not always the case,
however. For example, if you start a command prompt session and attempt to redirect the output of a DIR command to a file in the root (as described earlier), the command will fail with an Access is denied error. Vista doesn’t prompt you for credentials, it just aborts the operation.
To work around this problem, right-click the
program you want to run and then click Run As Administrator. Enter your
credentials and Windows Vista starts the program with the privileges of
the Administrator account, which allows you to do anything you want.
Tip
In some cases, you might be able to set things
up to always run a program under the Administrator account. Create a
shortcut to the executable file, right-click the shortcut, and then
click Properties. In the Compatibility tab, activate the Run This
Program As an Administrator check box. Click OK.
It’s worth noting here that if you need to run a program as a specific user, you can use the RUNAS command-line tool. You use RUNAS
at the command prompt to specify the username, and Windows Vista then
prompts you to enter the user’s password. Here’s the basic syntax (type RUNAS /? for the complete list of switches):
RUNAS /user:domain\user
program
|
|
---|
/user: domain\user | The user name under which you want the program to run. Replace domain with either the computer name (for a standalone or workgroup machine) or the domain name. |
program | The
full pathname and filename of the application. You need only use the
file’s primary name if the application resides within the current
folder, the %SystemRoot% folder, the %SystemRoot%\System32 folder, or a folder in the PATH variable. |
Creating Application-Specific Paths
Earlier I told you about application-specific
paths, which enable you to launch almost any 32-bit application simply
by typing the name of its executable file, either in the Run dialog box
or at the command prompt. You don’t need to spell out the complete
pathname. This pathless execution is handy, but it doesn’t work in the
following two situations:
16-bit applications— These older programs don’t store the paths to their executables in the Registry.
Documents—
You can’t load a document just by typing its filename in the Run dialog
box or at the command prompt unless the document is in the current
folder.
To
solve both these problems, and to handle the rare case when a 32-bit
application doesn’t create its own application-specific path, you can
edit the Registry to add a path to an executable file (an
application-specific path) or to a document (a document-specific path).
In the Registry Editor, open the following key:
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths
The App Paths key has subkeys for each installed 32-bit application. Each of these subkeys has one or both of the following settings:
Default— This setting spells out the path to the application’s executable file. All the App Paths subkeys have this setting.
Path—
This setting specifies one or more folders that contain files needed by
the application. An application first looks for its files in the same
folder as its executable file. If it can’t find what it needs there, it
checks the folder or folders listed in the Path setting. Not all App Paths subkeys use this setting.
To create an application-specific path, select the App Paths key,
create a new subkey, and assign it the name of the application’s
executable file. For example, if the program’s executable filename is OLDAPP.EXE, name the new subkey OLDAPP.EXE. For this new subkey, change the Default setting to the full pathname of the executable file.
Tip
You don’t have to give the new App Paths subkey the name of the executable file. You can use any name you like as long as it ends with .exe and doesn’t conflict with the name of an existing subkey.
Why does it have to end with .exe?
Unless you specify otherwise, Windows Vista assumes that anything you
enter in the Run dialog box or at the command prompt ends with .exe. Therefore, by ending the subkey with .exe, you need to type only the subkey’s primary name. For example, if you name your new subkey OLDAPP.EXE, you can run the program by typing oldapp in the Run dialog box or at the command prompt.
You create document-specific paths the same way.
(However, the document’s file type must be registered with Windows
Vista.) In that case, though, the Default setting takes on the full
pathname of the document. Again, if you want to load the document just
by typing its primary name, make sure that the new App Paths subkey uses the .exe extension.
Controlling Startup Programs with Windows Defender
For our purposes, Windows Defender comes with a feature called Software
Explorer that enables you to view information about four types of
programs: startup programs, currently running programs, network
connected programs, and Winsock service providers. For the startup
programs, you can use Software Explorer to either temporarily disable a
program from running at startup, or you can remove it altogether from
whatever startup nook it resides in (the Startup folder, a Registry key,
and so on). Here are the steps to follow:
1. | Select Start, All Programs, Windows Defender.
|
2. | Click Tools.
|
3. | Click Software Explorer and then enter your credentials when the User Account Control dialog box appears.
|
4. | In
the Software Explorer window, make sure that Startup Program is
selected in the Category list. Windows Defender displays a list of
programs that run at startup, as shown in Figure 2.
|
5. | Click the program you want to work with. The Software Explorer displays the program’s details on the right side of the window.
|
6. | To
temporarily prevent a program from running at startup, click Disable.
If you never want to run the program at startup, click Remove instead.
|
7. | When Windows Defender asks you to confirm, click Yes. |