Make Windows Start and Stop the Way You Want |
|
Scott Dunn From the June 2011 issue of PC World magazine
(2K, XP, 98, ME) Want to run an application each time Windows starts? Easy. Just right-drag its .exe file, or a shortcut to that file, to the Startup folder and choose Create Shortcut(s) Here. The next time you start Windows, the program will load automatically. But what about scanning for viruses, making backups, defragmenting your hard drive, and doing other regular maintenance tasks? You don't want to wait for them to finish every time you start up.
The Scheduled Tasks feature in Windows can run those activities while you're away from your system--but only if you leave your computer on all the time. If you prefer to save power by shutting down your PC every day, tell Windows to do its chores just before it shuts down. Or even better, create a shutdown folder whose contents you can change at will, knowing that Windows will run the items in the folder when it shuts down.
This allows you to put the whammy on applications that run uninvited at startup by constantly reinserting themselves into the Registry. First I'll show you how to add a shutdown folder to Windows without buying any additional software. Then I'll describe how to create a Registry file that wipes out unwanted entries every time you turn off your system. A batch file sent in by John F. Vogele of Santa Fe, New Mexico, inspired this tip.
First, create your shutdown folder. Note that launching items from a folder at shutdown works only with Windows 2000 and XP, so Windows 9x and Me users can skip this step and follow the instructions below for running programs at shutdown. To keep your shutdown folder with your Startup folder, right-click the Start button and click Open. Double-click Programs and then select File, New, Folder. Type Shutdown and press Enter to give the folder a name. Press Enter again to open the folder, and then fill it with shortcuts to any programs you want to run at shutdown: Use the right-mouse button to drag an item from any menu or folder window to your Shutdown folder and choose Create Shortcut(s) Here (in XP) or Copy Here (in 2000).
The programs start just before your computer powers down, so add only utilities and batch files that automatically shut down or stop their tasks when they finish (see FIGURE 1 ). To do this with disk maintenance utilities, you may need to set some special command-line switches; see the September 2003 Windows Tips for details. And read " Windows Tips: Superscrub Your Drive Automatically," from the December 2000 issue, for tips on automating Disk Cleanup. You can also add a batch file that backs up your work or a shortcut that performs a virus scan. Consult your antivirus software for any necessary command-line options.
The names of the shortcuts in your Shutdown folder cannot contain any spaces. If you see a shortcut name that does have a space, select it, press F2, type a space-free name, and press Enter. Repeat as needed for all such shortcuts.
Shutdown Maintenance
Now create a batch file to launch these applications and shut down your computer. Select Start, Programs (All Programs in XP), Accessories, Notepad. The first three lines of the batch file, which will launch the applications in your Shutdown folder, apply only to Windows 2000 and XP. On the first line, type dir /b followed by the path to your Shutdown folder (in quotation marks if it contains any spaces or long folder names). On the same line, type a space and > (the "greater than" symbol) followed by the path to the folder that will store the batch file, and finally a name for the batch file that lists your shutdown applications. To find the file path, simply open the folder in Explorer and look in the Address field. (If you don't see it there, click Tools, Folder Options, View, Display the full path in the address bar.) The /b switch in the command causes it to list only file names, without extra information. For example, your first line might look like this: dir /b "C:\Documents and Settings\Scott\Start Menu\Programs\Shutdown">"c:\batch\run_it.bat" (your paths may differ, of course).
On the second line, type cd /d and enter the path to the directory containing your Shutdown folder again. (The /d switch simply ensures that the prompt points to the correct drive.) For example, the second line of your batch file might look like this: cd /d "C:\Documents and Settings\Scott\Start Menu\Programs\Shutdown" (your path may differ, of course).
The next line will launch the batch file. Type a command like this: call c:\batch\run_it.bat (again, your path may differ).
In all Windows versions, add a line for each utility you want to launch that does not have a corresponding shortcut in your Shutdown folder. In Windows 9x and Me, this is the only way to get programs to launch just prior to Windows shutting down. For example, you might have a line like c:\windows\scandskw.exe c: d: /n (your application and command-line options may differ, naturally). If you add Windows utilities that automatically exit upon completion, add start /w to the beginning of their lines, particularly if the tasks take a while. The /w switch causes the batch file to pause until the application has shut down before going to the next line.
Add a line to the batch file to shut down Windows. Browse to January's " Windows Tips" and scroll to "One-Click Exits and Reboots" for the full scoop. If you'd like to use Windows XP or 2000 to launch applications by putting them in your Shutdown folder, adjust the '-t' (timeout) option to give these tasks enough time to finish before Windows shuts down. Type -t , followed by a space, and then enter the number of seconds you want the shutdown process to wait. For example, the command -t 9999 will cause Windows to wait nearly 3 hours before shutting down. When you're done, your Notepad window may look like the one in FIGURE 2 .
Now choose File, Save, navigate to the folder where you store batch files, and give your file a name with the .bat extension--for example, Shutdwn.bat . Next, open the folder in Explorer and drag the icon for the file you just saved onto the Start menu button. Click the Start button, right-click your new command, and select Rename (if you want to change its name) or Properties (if you want to customize its look via the Change Icon button on the Program or Shortcut tab). The next time you want to exit Windows and automatically run your shutdown applications, choose this icon on the Start menu instead of selecting the usual command.
Stop Autostart Apps
(2K, XP, 98, ME) One handy use for a shutdown folder is to clear persistent folderol from your Registry. Many apps try to keep themselves or one of their modules running in your system tray (the area near the clock) even when you're not using them. Most of these Startup items are placed here when you first install the program. If you use them only occasionally, you can prevent them from starting by using a handy freeware tool such as Mike Lin's Startup Control Panel. You can download Startup Control Panel 2.8 from PC World's Downloads page.
Unfortunately, some applications (such as QuickTime for Windows) restore their startup commands every time you upgrade or even just run the application. Before you can clean them out automatically, you need to edit the Registry key in question. Choose Start, Run, type regedit , and press Enter. Navigate to the folder (called a "key" in Registry lingo) containing the command to start the application. Startup Control Panel can show you where to look, but the most likely places are HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run and HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. The QuickTime Task module, for example, uses the latter.
With the key selected in the tree pane on the left, choose Registry, Export or File, Export (depending on your version of Windows). Navigate to your backup folder, make sure that Selected branch is highlighted, give the export file a name, and click Save (see FIGURE 3 ).
Back in the Registry, choose the Export command again, but this time specify a folder for storing a modified version that you can use to delete unwanted Startup items. If you plan to make this correction via a batch file (like the one described in the previous tip), you may store this version in the same folder as your batch files. Again, confirm that Selected branch is highlighted, type a name, and click Save.
Open Explorer and locate the icon for the export file you just saved. Right-click the icon and choose Edit. Don't make any changes to the top line, the blank line below that, or the next heading line that shows the Registry path in brackets. Underneath that heading, one or more applications will be listed in quotation marks. Find the line that corresponds to the application whose startup command you would like to remove. Leave the line intact up to the equal sign (=), but delete everything on the line after that. Type a hyphen immediately after the equal sign. For example, if you're eliminating the QuickTime Task item, the line should now read "QuickTime Task"=- . Repeat these steps for all the applications you want to prevent from starting with Windows.
Finally, delete all of the other lines beneath the bracketed heading. When you are finished, you should be left with only the two headings at the top (showing the Registry version and the bracketed Registry path) and one line for each application whose behavior you want to modify (see FIGURE 4 ). Choose File, Save to preserve your custom .reg file.
Double-click the Registry export icon and follow the prompts to keep unwanted applications from starting with Windows. To create a shortcut that responds automatically, right-click inside the desired folder (such as the Shutdown folder you created in the previous tip) and choose New, Shortcut. In the first box in the Create Shortcut wizard, type regedit /s followed by a space and the path to your modified .reg file. So if you stored your file in C:\Windows\Batch, your line might read regedit /s "C:\Windows\Batch\Startup Stopper.reg" (your path and file name may differ). Use quotation marks if your path contains a space or uses long names. Click Next, type a name for your shortcut, and click Finish.
Send Windows-related questions and tips to scott_dunn@pcworld.com. We pay $50 for published items.You'll find more Windows Tips here. Scott Dunn is a contributing editor for PC World.
|