Saturday, November 28, 2009

Batch files use this link

http://www.robvanderwoude.com/shorts.php

Batch file world

RUNDLL and RUNDLL32
RUNDLL and RUNDLL32 are two utilities supplied with Windows 95 and later.They can call DLL functions from the command line, allowing us to create extremely powerfull batch files.
Some examples:
Start Control Panel applets (2)
Open Install new modem wizard
Start "Add New Hardware" wizard
Open the "Unplug or Eject Hardware" wizard (Windows 95)
Open Device manager
Install a screensaver
Lock the screen (Windows 2000)
Redraw the screen (Windows 95)
Rearrange the windows on the screen (Windows 95)
Change screen resolution (Windows 9x with PowerToys' QuickRes installed)
Disable mouse and/or keyboard (Windows 9*/ME)
Halt system
Start "Add New Printer" wizard
Open "Connect to Printer" dialog
Open the Printers folder
Print a test page (Windows 95 and later)
Manage printer settings (Windows 2000)
Add a TCP/IP printer port
Clear Internet Explorer branding (the annoying company name in IE's title bar)
Open the dialog box for editing the Favorites in Internet Explorer
Delete Internet Explorer 7's browsing history, cookies and temporary files
Start GUI mode disk format
Start GUI mode diskcopy
"Map Network Drive" dialog (Windows 95)
Manage shares
Create a new share
Open the Network ID wizard
Open the Add network place wizard
Logoff Windows (1)
Reboot (1)
Shutdown (1)
Activate suspend mode (1) (Windows 2000 and later)
Show "System setting changed, do you want to reboot now?" dialog (Windows 9*)
Display NT's "About" dialog
Open a file with Windows' "Open as" dialog
Open a .ZIP file in Explorer (Windows XP)
Swap your mouse to left handed use
Start "DialUp Connection" wizard (Windows 95)
Start DialUp Network
Open the Fonts folder
Open an Active Directory Search dialog (Windows 2000 and later)
Activate registry changes in HKEY_CURRENT_USER without logging off (Windows 2000 and later)
Remove Messenger (Windows XP)
Repair IE 6 (Windows XP)

Start Control Panel applets (2)
General syntax:
RUNDLL32 SHELL32.DLL,Control_RunDLL filename.CPL,@n,t
where:
filename.CPL
is the name of one of Control Panel's *.CPL files,
n
is the zero based number of the applet within the *.CPL file, and
t
is the number of the tab for multi paged applets
Examples:
Date/time applet, Time Zone tab:
RUNDLL32 SHELL32.DLL,Control_RunDLL TIMEDATE.CPL,@0,1
Desktop applet, Screensaver tab:
RUNDLL32 SHELL32.DLL,Control_RunDLL DESK.CPL,@0,1
Network applet, Protocols tab:
RUNDLL32 SHELL32.DLL,Control_RunDLL NCPA.CPL,@0,2
Network applet, Adapters tab:
RUNDLL32 SHELL32.DLL,Control_RunDLL NCPA.CPL,@0,3
System applet, Environment tab:
RUNDLL32 SHELL32.DLL,Control_RunDLL SYSDM.CPL,@0,2
An alternative approach is using CONTROL.EXE.However, if you want to make your batch file wait for the Control Panel applet to be closed, you'll have to use the RUNDLL32 command with START /WAIT
General syntax:
CONTROL.EXE filename.CPL,@n,t
where:
filename.CPL
is the name of one of Control Panel's *.CPL files,
n
is the zero based number of the applet within the *.CPL file, and
t
is the number of the tab for multi paged applets
Examples:
Date/time applet, Time Zone tab:
CONTROL.EXE TIMEDATE.CPL,@0,1
Desktop applet, Screensaver tab:
CONTROL.EXE DESK.CPL,@0,1
or alternatively, in Windows 2000 & XP:
CONTROL.EXE DESK.CPL ,@ScreenSaver
Note the space between the *.CPL file name and the comma.This seems to work for DESK.CPL only.Use the description on the tab, remove any spaces.Credits: Neil J. Rubenking, in one of his articles in PC Magazine.Tip: Leslie Katz

Back to the top of this page . . .
Open Install new modem wizard
RUNDLL32 modemui.dll,InvokeControlPanel
Credits: Jeffrey W. Horning (posted on JSI FAQ)

Back to the top of this page . . .
Start "Add New Hardware" Wizard
(Windows 95)
RUNDLL SYSDM.CPL,InstallDevice_Rundll
Credits: Faris Mlaeb

Back to the top of this page . . .
Open the "Unplug or Eject Hardware" wizard
(Windows 2000 or later, or Windows 98 SE with hotplug.dll installed):
RUNDLL32 SHELL32.DLL,Control_RunDLL hotplug.dll
Credits: Chris S./Dx21.com

Back to the top of this page . . .
Open Device manager
RUNDLL32 devmgr.dll DeviceManager_Execute
Credits: Jeffrey W. Horning (posted on JSI FAQ)

Back to the top of this page . . .
Install a screensaver
(copy the *.SCR file to the Windows directory first) (2):
RUNDLL32 DESK.CPL,InstallScreenSaver C:\WINNT\SYSTEM32\Default.scr
(To invoke the screensaver use:
C:\WINNT\SYSTEM32\Default.scr /S
Tip by "UnhappyEggWhisk" on forums.somethingawful.com)
The directory shown is for Windows NT 4/2000, modify for Windows 9x/XP

Back to the top of this page . . .
Lock the screen
(Windows 2000)
RUNDLL32 USER32.DLL,LockWorkStation
Credits: Steven Clements (posted on alt.msdos.batch.nt)

Back to the top of this page . . .
Redraw the screen
(Windows 95)
RUNDLL USER,repaintscreen
Credits: Faris Mlaeb

Back to the top of this page . . .
Rearrange the windows on the screen
(Windows 95)
Cascade:
RUNDLL32 USER,cascadechildwindows
Tile:
RUNDLL32 USER,tilechildwindows
Credits: Faris Mlaeb

Back to the top of this page . . .
Change screen resolution
(Windows 9x with PowerToys' QuickRes installed):
RUNDLL DESKCP16.DLL,QUICKRES_RUNDLLENTRY hresxvresxbpp
Where hres is the horizontal resolution in pixels, vres is the vertical resolution in pixels, and bpp is the number of bits per pixel.The following example will set the screen resolution to 800 x 600 at 256 colors (28 colors = 8 bits per pixel)
RUNDLL DESKCP16.DLL,QUICKRES_RUNDLLENTRY 800x600x8
Credits: William Allen (posted on alt.msdos.batch)

Back to the top of this page . . .
Disable mouse and/or keyboard
(Windows 9*/ME)
RUNDLL KEYBOARD,DISABLERUNDLL MOUSE,DISABLE
There is an ENABLE function too, but I haven't found the right syntax yet. Without any further parameters it only halts the system without warning (Windows 95). You will probably need the other RUNDLL commands to do a "clean" reboot.
Credits: Koro das Master

Back to the top of this page . . .
Halt system
RUNDLL MOUSE,ENABLE
Credits: Faris Mlaeb

Back to the top of this page . . .
Start "Add New Printer" wizard
RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL AddPrinter

Back to the top of this page . . .
Open "Connect to Printer" dialog
RUNDLL32 WINSPOOL.DRV,ConnectToPrinterDlg
This commands opens the "Connect to Printer" dialog, as you might have guessed. I don't see any useful application yet, but maybe you do.

Back to the top of this page . . .
Open the Printers folder
RUNDLL32 SHELL32.DLL,Control_RunDLL MAIN.CPL @2
or for Windows 2000:
RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL PrintersFolder
Credits: Pascal Rebsamen
Note:
To create a shortcut in the Start Menu to open the Printers folder, create a directory using one of the following commands.
Windows 9x (without roaming profiles):
MD "%windir%\Start Menu\Programs\Printers.{2227A280-3AEA-1069-A2DE-08002B30309D}"
Windows NT 4/2000:
MD "%USERPROFILE%\Start Menu\Programs\Printers.{2227A280-3AEA-1069-A2DE-08002B30309D}"

Back to the top of this page . . .
Print a test page
(Windows 95 and later; unfortunately this command does not always work):
RUNDLL32.EXE SHELL32.DLL,SHHelpShortcuts_RunDLL PrintTestPage
Or for Windows 9x (source: Daniel U. Thibault):
RUNDLL32.EXE MSPrint2.DLL,RUNDLL_PrintTestPage

Back to the top of this page . . .
Manage printer settings
(Windows 2000)
RUNDLL32 PRINTUI.DLL,PrintUIEntry /?
This will display an extensive list of available functions and many examples.View this same list in HTML.

Back to the top of this page . . .
Add a TCP/IP printer port
RUNDLL32 tcpmonui.dll,LocalAddPortUI
Credits: Jeffrey W. Horning (posted on JSI FAQ)

Back to the top of this page . . .
Clear Internet Explorer branding
(the annoying company name in IE's title bar)
RUNDLL32.EXE iedkcs32.dll,Clear
Credits: "pradeep" (posted on Go4Expert Forum)

Back to the top of this page . . .
Open the dialog box for editing the Favorites in Internet Explorer
RUNDLL32.EXE shdocvw.dll,DoOrganizeFavDlg
Credits: "pradeep" (posted on Go4Expert Forum)

Back to the top of this page . . .
Delete Internet Explorer 7's browsing history, cookies and temporary files
RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess n
Where n can have the following values:
1
delete browsing history (list of visited sites)
2
delete all cookies
8
delete temporary files (cache)
16
delete all saved forms data
32
delete all saved passwords
255
delete all of the above
4351
delete all of the above and all settings stored by add-ons
The use of powers of 2 suggests that one can combine (add) these values, e.g. 40 to delete temporary files (8) and passwords (32) simultaneously, but I didn't test this assumption yet.
Credits: Herby on neowin.net

Back to the top of this page . . .
Start GUI mode disk format
RUNDLL32 SHELL32.DLL,SHFormatDrive
Back to the top of this page . . .
Start GUI mode diskcopy
RUNDLL32 DISKCOPY.DLL,DiskCopyRunDll
Credits: Media Chance

Back to the top of this page . . .
"Map Network Drive" dialog
(Windows 95)
RUNDLL32 USER,wnetconnectdialog
and for Windows XP:
RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL Connect
Credits: Faris Mlaeb (Windows 95) and Ian Freeman (Windows XP)

Back to the top of this page . . .
Manage shares
RUNDLL32 ntlanui.dll,ShareManage - Shares
Credits: Jeffrey W. Horning (posted on JSI FAQ)

Back to the top of this page . . .
Create a new share
RUNDLL32 ntlanui.dll,ShareCreate
Credits: Jeffrey W. Horning (posted on JSI FAQ)

Back to the top of this page . . .
Open the Network ID wizard
RUNDLL32 netplwiz.dll,NetAccWizRunDll
Credits: Jeffrey W. Horning (posted on JSI FAQ)

Back to the top of this page . . .
Open the Add network place wizard
RUNDLL32 netplwiz.dll,AddNetPlaceRunDll
Credits: Jeffrey W. Horning (posted on JSI FAQ)

Back to the top of this page . . .
Logoff Windows (1)
Logoff Windows 98:
RUNDLL SHELL32.DLL,SHExitWindowsEx
Logoff Windows 98 and run Explorer after relogon:
RUNDLL SHELL32.DLL,SHExitWindowsEx 4
Logoff Windows NT 4:
RUNDLL32 USER32.DLL,ExitWindowsExRUNDLL32 USER32.DLL,ExitWindowsEx
This is not a mistake, the command usualy must be called twice before anything happens.

Back to the top of this page . . .
Reboot (1)
Windows 95 (not reliable, sometimes only shutdown):
RUNDLL USER.EXE,ExitWindowsExec
Windows 98:
RUNDLL SHELL32.DLL,SHExitWindowsEx 2
Windows NT 4:
@ECHO OFFPUSHD "%temp%"ECHO [Version] > {out}.infECHO signature=$chicago$ >> {out}.infECHO [defaultinstall] >> {out}.infRUNDLL32 SETUPAPI,InstallHinfSection DefaultInstall 1 {out}.infDEL {out}.infPOPD
(original batch file by Walter Zackery, adapted for readability)

Back to the top of this page . . .
Shutdown (1)
Windows 95:
RUNDLL USER.EXE,ExitWindows
Windows 98:
RUNDLL SHELL32.DLL,SHExitWindowsEx 1
or:
RUNDLL32 KRNL386.EXE,exitkernel
(will also power down ATX boards)

Back to the top of this page . . .
Activate suspend mode (1)
(Windows 2000/XP)
RUNDLL32 PowrProf.dll, SetSuspendState
Credits: TechRepublic's Windows XP Newsletter & Graham Smith.

Back to the top of this page . . .
Show "System setting changed, do you want to reboot now?" dialog (1):
(Windows 9*)
RUNDLL SHELL.DLL,RestartDialog

Back to the top of this page . . .
Display NT's "About" dialog
Showing version, servicepack, registered owner and amount of physical memory:
RUNDLL32 SHELL32.DLL,ShellAboutW

Back to the top of this page . . .
Open a file with Windows' "Open as" dialog
RUNDLL32 SHELL32.DLL,OpenAs_RunDLL filename

Back to the top of this page . . .
Open a .ZIP file in Explorer
(Windows XP)
RUNDLL32.EXE ZIPFLDR.DLL,RouteTheCall zipfile.ZIP
Unfortunately, there seems to be no (native) command to copy files into the .ZIP file

Back to the top of this page . . .
Swap your mouse to left handed use
(tip from "Speedy Gonzales")
Windows 95:
RUNDLL USER.EXE,SwapMouseButton
Windows NT:
RUNDLL32 USER32.DLL,SwapMouseButton
I know of no command yet to undo this, but the following will get you close:
CONTROL MAIN.CPL
or:
RUNDLL32 SHELL32.DLL,Control_RunDLL MAIN.CPL,@0,1

Back to the top of this page . . .
Start "DialUp Connection" Wizard
(Windows 95)
RUNDLL RNAUI.DLL,RnaWizard
Credits: Faris Mlaeb

Back to the top of this page . . .
Start DialUp Network
START RUNDLL32 RNAUI.DLL,RnaDial exact name of dialer entryTRACERT -h 1 -w 1
The RUNDLL command starts DUN, the TRACERT command is supposed to actually start the dialing process, assuming automatic dialing is enabled.Since I do not have access to any PC with DUN installed, I could not test the TRACERT command's effect.
Credits for these commands: Michael J. Gregg and Tom Lavedas
Use the RASPHONE command in Windows NT, which can also hang up the connection
Credits: Simon Sheppard.

Back to the top of this page . . .
Open the Fonts folder
RUNDLL32 SHELL32.DLL,SHHelpShortcuts_RunDLL FontsFolder
Credits: Media Chance

Back to the top of this page . . .
Open an Active Directory Search window:
RUNDLL32 dsquery,OpenQueryWindow
This allows you to search Active Directory for users or computers, though only a limited part of the properties is accessible.
Credits: TechRepublic's Windows XP e-Newsletter for August 5, 2004

Back to the top of this page . . .
Activate registry changes
in HKEY_CURRENT_USER without logging off (Windows 2000 and later):
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True
Credits: Pete Smith.

Back to the top of this page . . .
Remove Messenger
(Windows XP)
RUNDLL32 advpack.dll,LaunchINFSection %windir%\INF\msmsgs.inf,BLC.Remove
Credits: Pascal Rebsamen (posted on WinBoard)

Back to the top of this page . . .
Repair IE 6
(Windows XP)
RUNDLL32 setupapi,InstallHinfSection DefaultInstall 132 %windir%infie.inf
Credits: Pascal Rebsamen (posted on WinBoard)

Back to the top of this page . . .

Notes:
(1)
See my Shutdown page for more information and examples on reboot and shutdown command lines.

(2)
By associating *.CPL files with the commandRUNDLL32 SHELL32.DLL,Control_RunDLL %1,@0and *.SCR files withRUNDLL32 DESK.CPL,InstallScreenSaver %1you can open and/or install them by doubleclicking on their icons.

Back to the top of this page . . .

Examples
Install a screensaver
The following batch file installs a screensaver if one is specified, and opens the Control Panel applet at the right tab to enable adjustment of its settings (tested in NT only):@ECHO OFF
IF "%1"=="" GOTO Interactive
IF NOT EXIST %SystemRoot%.\System32\%~nx1 GOTO Interactive
RUNDLL32 DESK.CPL,InstallScreenSaver %~f1
GOTO End
:Interactive
RUNDLL32 SHELL32.DLL,Control_RunDLL DESK.CPL,@0,1
:End




I am interested to hear about other possible uses for RUNDLL32.Please send me your tips or comments by e-mail: info@robvanderwoude.com

Back to the top of this page . . .

More to explore

An extensive list of RUNDLL commands with good search capabilities can be found at Dx21's RunDLL32 section.
For programmers, there is more information on Microsoft's Windows 95 Rundll and Rundll32 Interface page.
Peter A. Bromberg's Short RunDll32 Primer for Developers.
At The Visual Basic Developers Resource Centre a list of Control Panel Functions for Windows 9x/NT through RUNDLL can be found (a tip from my former collegue Adriaan Westra; thanks).
An extensive list of Control Panel related and other RUNDLL commands can be found at Media Chance's RUNDLL FAQ page.
Jeffrey W. Horning provided a list of Undocuments paths to Windows 2000 tools (thanks for Viju Chellamuthu, who mailed me the link).
Search Microsoft.com for more info on INF files.

Batch file for auto delete temp files

REM Deletes Temporary Internet Filescd /d c:\Documents and Settings
for /d %%X in (*) do rd /s /q "C:\Documents and Settings\%%X\Local
Settings\Temporary Internet Files"REM Deletes All User's temp filesfor /d %%X in (*) do rd /s /q "C:\Documents and Settings\%%X\Local
Settings\Temp"REM Deletes Windows and WINNT Temp
rd /s /q %SystemRoot%\temp\*.*REM Deletes Microsoft Update filesset unf=%SystemRoot%\$NtUninstall*
for /f "Tokens=*" %%i in ('dir /B /AD %unf%') do rd /s /q
"%SystemRoot%\%%i"set unf=%SystemRoot%\$MSI31Uninstall*
for /f "Tokens=*" %%i in ('dir /B /AD %unf%') do rd /s /q
"%SystemRoot%\%%i"set unf=%SystemRoot%\$NtServicePack*
for /f "Tokens=*" %%i in ('dir /B /AD %unf%') do rd /s /q
"%SystemRoot%\%%i"
<*((((><{
Fishy@xxxxxxxxx
.
Prev by Date: Re: Unable to connect to windows update site
Next by Date: Re: Fatal Execution Engine Error - Error Code 0x7925dc14
Previous by thread: Updates were unable to be successfully installed.
Next by thread: Automatic Update
Index(es):
Date
Thread

powered by
Custom Search Control
Web



google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function(){
var customSearchControl = new google.search.CustomSearchControl('partner-pub-3777565888511862:94wms0v2qun');
customSearchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
customSearchControl.draw('cse');
}, true);
.gsc-control-cse {
font-family: Arial, sans-serif;
border-color: #808080;
background-color: #FFFFFF;
}
input.gsc-input {
border-color: #BCCDF0;
}
input.gsc-search-button {
border-color: #336699;
background-color: #E9E9E9;
}
.gsc-tabHeader.gsc-tabhInactive {
border-color: #E9E9E9;
background-color: #E9E9E9;
}
.gsc-tabHeader.gsc-tabhActive {
border-top-color: #FF9900;
border-left-color: #E9E9E9;
border-right-color: #E9E9E9;
background-color: #FFFFFF;
}
.gsc-tabsArea {
border-color: #E9E9E9;
}
.gsc-webResult.gsc-result {
border-color: #FFFFFF;
background-color: #FFFFFF;
}
.gsc-webResult.gsc-result:hover {
border-color: #FFFFFF;
background-color: #FFFFFF;
}
.gs-webResult.gs-result a.gs-title:link,
.gs-webResult.gs-result a.gs-title:link b {
color: #003366;
}
.gs-webResult.gs-result a.gs-title:visited,
.gs-webResult.gs-result a.gs-title:visited b {
color: #616366;
}
.gs-webResult.gs-result a.gs-title:hover,
.gs-webResult.gs-result a.gs-title:hover b {
color: #0000FF;
}
.gs-webResult.gs-result a.gs-title:active,
.gs-webResult.gs-result a.gs-title:active b {
color: #0000FF;
}
.gsc-cursor-page {
color: #003366;
}
a.gsc-trailing-more-results:link {
color: #003366;
}
.gs-webResult.gs-result .gs-snippet {
color: #000000;
}
.gs-webResult.gs-result .gs-visibleUrl {
color: #000000;
}
.gs-webResult.gs-result .gs-visibleUrl-short {
color: #000000;
}
.gsc-cursor-box {
border-color: #FFFFFF;
}
.gsc-results .gsc-cursor-page {
border-color: #E9E9E9;
background-color: #FFFFFF;
}
.gsc-results .gsc-cursor-page.gsc-cursor-current-page {
border-color: #FF9900;
background-color: #FFFFFF;
}
.gs-promotion.gs-result {
border-color: #336699;
background-color: #FFFFFF;
}
.gs-promotion.gs-result a.gs-title:link {
color: #0000CC;
}
.gs-promotion.gs-result a.gs-title:visited {
color: #0000CC;
}
.gs-promotion.gs-result a.gs-title:hover {
color: #0000CC;
}
.gs-promotion.gs-result a.gs-title:active {
color: #0000CC;
}
.gs-promotion.gs-result .gs-snippet {
color: #000000;
}
.gs-promotion.gs-result .gs-visibleUrl,
.gs-promotion.gs-result .gs-visibleUrl-short {
color: #008000;
}
(17)

Hey do u have several google talk accounts,wanna run multiple instances of google talk at once. catch it here

Run google talk with the following switch: /nomutex
If you installed google talk to the default location, you can easily create a shortcut to this setting.
1. Right-click on the desktop2. Select New3. Select Shortcut4. Paste this into the text box:
“c:program filesgooglegoogle talkgoogletalk.exe” /nomutex
5. Click Next6. Name it whatever: Google Talk Multiple, etc.7. Click OK until you are done.

Tips and tricks

A Faster Way to Encrypt Your Files By Diana Huggins

If your drives are formatted with NTFS, you have the option of using encryption. Windows XP uses the Encrypting File System (EFS) which lets you encrypt your folders and files for increased security. Normally to encrypt a folder or file, you would have to do so from the folder or file's properties window and access the advanced attributes. Wouldn't it be great though if you could just encrypt or decrypt a file or folder using the shortcut menu?

Well here's a nifty little tip that does just that... it adds the encrypt and decrypt options to the shortcut menu for a folder or file. Of course, a word of caution: the following steps do require you to modify the registry, so proceed carefully:


Click Start, point to run, and type regedit.
Within the Registry Editor, navigate to the following subkey:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced.
Click the Edit menu, point to New, and select Dword value.
Type in EncryptionContextMenu. Configure the value as 1.
You should now be able to encrypt or decrypt any of your folders and files using the shortcut menu.* 04/28/2004



--------------------------------------------------------------------------------


Boot into Safe Mode

It is often recommended to boot into Safe Mode in order to run anti-spyware/virus/etc scans. You can do so by repeatedly hitting the F8 key while the computer is starting up.

However, since hitting the F8 key constantly to boot into safe mode is annoying (to me), and sometimes despite doing that I still sometimes miss my window of opportunity to get into safe mode & have to let the PC boot into standard mode & restart. On my computers I always set it to pause & show me the option of booting into safe mode or the regular mode (which would be the default) every time the computer starts. This is how you can do the same:

Right-Click "My Computer" -> Properties -> Advanced -> Startup and Recovery -> Settings

On the new window, there is a bunch of settings at the top under "System Startup". For the Default Operating System, it will probably show something like "Microsoft Windows XP Home" /fastdetect OR Microsoft Windows XP Professional" /fastdetect" ... leave that alone.

Please notice that for this example I'll use "Windows XP Professional" for my computer Operating System...Substitute "Windows XP Home" if that is the Operating System you use.

Make sure the option for "Time to display list of operating systems" is checked. The default time is 30 seconds, I usually set the time to 10 seconds (sometimes even just 5).

Check the "Time do display recovery options" too (it should already be checked), and I leave it at the default 30 seconds.

Click the "Edit" button, and the boot.ini file will open in Notepad. It'll look something like this:

[boot loader]
timeout=10
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect

The last line is the OS boot option.

If there is only one option, then you will not see a menu on start up & your computer will just boot straight into Windows. Let's add a second option at the end of this file, like so:

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows XP Safe Mode with Network" /safeboot:network /sos /bootlog /noguiboot

(You can just Copy & Paste that line right into the boot.ini file.)

This will give you the option of starting in Safe Mode with Network Support (so you can still access the internet or local network if needed).

To add an option of having Safe Mode with No Networking, use this line:

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows XP Safe Mode" /safeboot:minimal /sos /bootlog /noguiboot

(Again, you can just Copy & Paste that line right into the boot.ini file.)

By the way, if the lines already in your boot.ini look different from the "multi(0)disk(0)rdisk(0)partition(1)" shown here, make sure that any new lines you add match what you've already got (ie. because you have Windows installed on a different drive/partition).

If you added both of these Safe Mode options, your file will now look something like this:

[boot loader]
timeout=10
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows XP Safe Mode with Network" /safeboot:network /sos /bootlog /noguiboot
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows XP Safe Mode" /safeboot:minimal /sos /bootlog /noguiboot

Save the file & close it & click Ok on any open dialogs. Next time you start the computer, you will see a little menu asking which boot option you want to use, with the default pre-selected (the default is the first one in the boot.ini file). If you don't make a choice (using cursor keys & Enter) before the timer counts down to zero, it'll use the default option.

As always, if you're nervous about manually changing settings for fear of messing things up, then leave things well enough alone and don't bother with this tweak. You can still get into Safe Mode by using the F8 key while starting the PC.

- Sriram Narayanan* 11/27/2006



--------------------------------------------------------------------------------


Change Colors Of Command Prompt Window (2k/XP)

I got this tip from Lockergnome Windows Fanatics - October 18, 2005 Newsletter.

To customize the colors of the Command Prompt Window Screen Background and Screen Text, first open a Command Prompt Window:

Click Start - Run - type "cmd" (without the quotes).

Once the Command Prompt Window opens, Click the Control Box in the top left corner of the Command Prompt Window (the button that looks like a C:\ Prompt).

Once the Menu opens, Click Properties - Colors - Screen Background - and change this to whatever color you wish to use. An example will be shown below, in the Selected Screen Colors dialog box, as you make different choices. Do the same for Screen Text.

As you can see, there are other options you can change here as well.

Once you're finished, Click OK, then type "exit" at the Command Prompt to exit the Command Prompt Window (without the quotes).



--------------------------------------------------------------------------------


Change the HungAppTimeout and/or WaitToKillAppTimeout Values - 95. Increasing shutdown speed by reducing wait times part 1

Open REGEDIT and navigate to 'HKEY_CURRENT_USER\Control Panel\Desktop\'
Highlight the 'WaitToKillAppTimeout' value.
Set it to '1000' (the default should be 20000).
Now highlight the 'HungAppTimeout' value
Set it to '1000' also.

Please notice that tip #96. Increasing shutdown speed by reducing wait times part 2 on the same page gives instructions for changing the same settings, but for All Users of the computer.



--------------------------------------------------------------------------------


Change the Internet Explorer Window Title - Start - Run - type regedit.exe - Enter - then navigate to - HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Window Title - and set it to blank. If this key is not present, add a String value and name it Window Title and modify the value, leaving the value blank.



--------------------------------------------------------------------------------


Change the size of and Defrag Win XP's Virtual Memory (Page File)

Two very important things you need to know: You will need to physically disconnect from the Internet while doing this and you must turn off ALL other programs that are running in the background.

First, let's Defrag the Page File. Make sure you have enough physical memory before attempting this Tweak! It can be done with 512MB RAM, but 1GB RAM is better.

Hold down the WinKey* and hit PauseBreak to open the System Properties - Advanced - Performance - Settings - Advanced - Virtual Memory - Change - select the proper Drive - No paging file - Set - OK your way out while OKing any warnings.

Reboot and now Defrag the HDD. Click Start - Administrative Tools - Computer Management - When that opens, on the Leftt Side click Disk Defragmenter - stretch this window larger so you can see all of the Hard Drives/Partitions - click on the Hard Drive/Partition you need to Defrag and click Defragment. When it finishes, click OK and Reboot once again.

Now let's re-enable the Page File and change the Page File size - Hold down the WinKey* and hit PauseBreak to open the System Properties - Advanced - Performance - Settings - Advanced - Virtual Memory - Change - select the proper Drive - Custom Size - set both Initial and Maximum to twice the size of physical memory you currently have installed (...meaning, if you have 512MB RAM, set both to 1024MB...If you have 1GB RAM, set both to 2048MB...) - Set - OK your way out while OKing any warnings. Reboot one last time.

Now the Page File will be Defragged and in one contiguous file.

* The WinKey is the Windows Flying Logo key between the CTRL and ALT keys.



--------------------------------------------------------------------------------


Controlling Cookies in Internet Explorer 6.0

Open Internet Explorer and go to Tools - Internet Options - go to Privacy - Advanced - check the Override automatic cookie handling box - then set First Party Cookies to Prompt and Third Party Cookies to Block and check the Always allow session cookies box. 08/15/2006



--------------------------------------------------------------------------------


Hacking Windows XP: Speed Up Your Boot - by Steve Sinchak - This is Chapter 8 from the ExtremeTech book Hacking Windows XP, published by Wiley. You can also read excerpts from the book about speeding disk access and speeding up your network and internet access.

No doubt you are surprised at how fast Windows XP boots up compared with other Microsoft operating systems. I certainly am, every time I start up the PC. This bootup time is something that everyone is becoming more concerned about as the need for PC speed becomes increasingly more important. Despite the relatively fast speed of Windows XP bootup time, this chapter will guide you through the steps of making the system boot up even faster. The changes discussed here should enable you to realize your bootup speed dreams.Your friends will then no doubt be impressed by your PC's superfast operation.

Windows XP has a lot of great features and visual enhancements that make Windows XP the most attractive OS from Microsoft to date. However, with all of the new features and attractive effects, the operating system has a higher system overhead, which means your hardware has to work even harder. If you are like me, and do not always have the fastest hardware, this chapter will help you get the most out of your current hardware by reducing the heavy workload put on it during the bootup process.* 11/11/2006



--------------------------------------------------------------------------------


Minimize Outlook 2002 to the System Tray - I got this Registry Tip from Sue Mosher's Awesome Outlook Web Site.

Make a backup of the Windows registry, then go to this key:

HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Preferences

Add a new DWORD value named "MinToTray" and give it a value of 1.* 04/27/2004

Oh Man! With as many open windows as I always have going at any one time, I only wish I had found this registry hack sooner!! If I understand correctly, it's an added "feature" of Outlook 2003.



--------------------------------------------------------------------------------


More Info in Device Manager - I got this Trick from the August 2003 edition of CPU Magazine:

If you'd like to have more information available than what Device Manager currently offers, go to Start-Control Panel-System (or hold down the Windows key (the one that looks like the Windows flag) and hit the Pause-Break key at the same time) and click on the Advanced tab in the System Properties window. Then click on the Environment Variables button and then New beneath the System Variables dialog box. In the Variable Name box type DEVMGR_SHOW_DETAILS (exactly as shown here) and in the Variable Value box type 1. Click OK as many times as necessary to close all dialog boxes and then reopen the System Properties-Device Manager window and choose any hardware item you'd like to see more info for and check out the new Details tab.* 07/12/2003



--------------------------------------------------------------------------------


Open Two Side-by-Side Instances of Windows Explorer Easily! - by Neil J. Rubenking - Start by launching your two instances of Windows Explorer. If Windows combines the taskbar buttons for the two windows into a single one with a title like "2 Windows Explorer," simply right-click that button and choose Tile Vertically from the pop-up menu. If each of them has its own button on the taskbar, do this: (1) Click one button; (2) Ctrl-click the other; (3) right-click either button; (4) choose Tile Vertically from the pop-up menu.

Here's another method, possibly necessary if you have more than two instances of Windows Explorer sharing a button on the taskbar: (1) Minimize all windows except the two Explorer instances; (2) right-click the taskbar itself; (3) choose Tile Windows Vertically from the pop-up menu.

I was informed that this would work with all Microsoft programs, not just Windows Explorer.* 09/20/2006



--------------------------------------------------------------------------------


Open Regedit in IE - One of the coolest tricks I saw lately came from one of my Students - Shay Levy.

Many tips published on various websites, including articles found on the Petri.co.il site, heavily use registry modifications and additions. These articles and tips usually tell you that in order to perform this or that, you need to open Regedit.exe (the registry editing tool), navigate to this or that registry path, and create, delete or modify registry keys and values.

In order to make your life easier, Shay has created this cool Internet Explorer add-in, that allows you to easily open Regedit and point it to the exact registry path, without the need to manually open Regedit.exe and begin to look for the relevant entry.* Awesome!! This is a MUST SEE Trick!! 04/10/2006



--------------------------------------------------------------------------------


Put The Command Prompt Where You Want It - I got this Registry Tip from the May 2004 edition of CPU Magazine:

For those of you using the command prompt frequently, you can add a registry key to enable right-clicking on any folder in Windows and have the command prompt run in a box already changed to that directory.

Run Regedit and find the HKEY_CLASSES_ROOT\Directory\shell key and right-click to make a New Key. Name the key cprompt, and in the Value pane set the key's default value to Command Prompt. (You can label this any way you wish. What happens is the context menu will pop-up on a folder with the label "Command Prompt," but you can give it any label you like.)

Go back and right-click the cprompt subkey to make another New Key. Name it command. Set the key's default value to C:\WINDOWS\SYSTEM32\cmd.exe /k cd "%1". Close regedit, and the effect should be immediate. Right-click on any folder and you should see Command Prompt in the context menu, and it will call up the command prompt in that subdirectory.* 04/25/2004

I tried this myself and it works great! Thanks CPU!

Friday, November 27, 2009

Xcopy and its Application

The syntax and use of the command "Xcopy" is described.
Of all the command line executables, Xcopy is one of the most useful for the average home PC user. It provides a powerful and versatile method for copying and backing up files and directories.
Syntax of Xcopy command
Xcopy has a large number of possible switches, which gives the command a great deal of flexibility. The syntax for the command is given by: XCOPY source [destination] [/A /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W] [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U] [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/EXCLUDE:file1[+file2][+file3]...]
Upper case letters have been used above but the command is case-insensitive. A description of the various switches is given in Table I. Note that Windows Vista has an additional switch "/B". The function of this switch is to copy a Symbolic Link itself instead of the target of the link.
Table I. Description of switches for the command Xcopy
Switch
Description
/A
Copies only files with the archive attribute set, doesn't change the attribute.
/M
Copies only files with the archive attribute set, turns off the archive attribute. Useful in backup.
/D:m-d-y
Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time. Useful in backup.
/P
Prompts you before creating each destination file.
/S
Copies directories and subdirectories except empty ones.
/E
Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T.
/V
Verifies each new file. Not used by Windows XP.
/W
Prompts you to press a key before copying.
/C
Continues copying even if errors occur.
/I
If destination does not exist and copying more than one file, assumes that destination must be a directory.
/Q
Does not display file names while copying.
/F
Displays full source and destination file names while copying.
/L
Displays files that would be copied.
/G
Allows the copying of encrypted files to destination that does not support encryption.
/H
Copies hidden and system files also.
/R
Overwrites read-only files.
/T
Creates directory structure, but does not copy files. Does not include empty directories or subdirectories.
/U
Copies only files that already exist in destination.
/K
Copies attributes. Normal Xcopy will reset read-only attributes.
/N
Copies using the generated "short" names. May be necessary when copying from NTFS to FAT16.
/O
Copies file ownership and ACL information.
/X
Copies file audit settings (implies /O).
/Y
Suppresses prompting to confirm that you want to overwrite an existing destination file. May be preset in the COPYCMD environment variable
/-Y
Prompts to confirm you want to overwrite an existing destination file.
/Z
Copies over a network in restartable mode.
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings to be excluded. Tricky to use. See below.
Applications of Xcopy
Xcopy provides an excellent tool for backing up selected folders. With appropriate switches, a variety of backup scenarios can be created. One possible backup configuration would be to copy only those files that have been changed. Here is an example command: xcopy C:\somefolder E:\backupfolder /D /E /C /R /H /I /K /Y This command will copy all files, including those in sub-folders, that are newer in the source folder. It will copy hidden as well as read-only files and will create the destination folder and/or sub-folders if they do not already exist.
The next example shows the use of a wildcard; it collects all files of a given type and copies them into one place. The command xcopy C:\*.mp3 E:\mp3folder /S /I /C > E:\mp3List.txt will collect all MP3 files on the C: drive and copy them to a folder on the E: drive. It also creates a list of the files copied and places the list on the E: drive. This simple command preserves the sub-folder structure. If desired, a more advanced script could be written that places all MP3 files in one folder with no sub-folders.
Excluding files and folders
A useful feature of Xcopy is the ability to exclude certain files and/or folders from being copied by means of the "/Exclude" switch. All names containing a given string of characters can be excluded. Unfortunately, Microsoft's description of the switch is neither a model of clarity nor accurate. In fact, postings on the Internet indicate considerable confusion exists about how to implement this handy feature. Perhaps the list below will help clarify how to use it.
The strings contained in the names of the files and/or folders to be excluded are not entered directly in the command switch itself.
The entry in the command switch is one or more text files that list the strings to be excluded.
The format of the switch is /Exclude:{path}list_of_exclusions.txt Note the colon between Exclude and the name of the file that lists the exclusions. Although more than one exclusion file can be used, stick with one if you can.
The name of the file that lists exclusions cannot have spaces. Quoting does not help.
Be careful with pathnames. Remember that operations are relative to the working directory for the command prompt. I suggest placing the exclusion list in the top directory of the directories being copied and opening the command prompt in the directory just above the directory and sub-directories to be copied. (Go here if you don't know how to open the command prompt wherever you want.) The various relative paths will then be simple. If you open the command prompt in the default location, things can get complicated.
The structure of the exclusions list is one exclusion string per line. Wildcards are not used and do not work. If you want to exclude all files whose names contain ABC, simply place ABC on one line of the exclusion file. If it is being used together with the switch "/S", the exclusion file will apply to sub-directories as well as the main directory.
To exclude a particular sub-directory, place its name in the exclusion file with backward slashes before and after its name, viz., \excluded_directory\
Use a text editor to create exclusion files. Do not use Microsoft Word or other word processor unless you are careful to create text files. Use ANSI encoding. When I tried UTF-8 encoding, the file did not work.
Exit codes for Xcopy
Many commands issue integer exit codes to indicate the status of the command after it is run. The exit codes for Xcopy are given in Table II. When placed in "If" statements, these error codes can be useful in batch files .
Table II. Exit codes for Xcopy
Exit code
Description
0
Files were copied without error.
1
No files were found to copy.
2
The user pressed Ctrl+C to terminate xcopy.
4
Various errors including insufficient memory or disk space, an invalid drive name, or invalid syntax.
5
Disk write error occurred.

Tips for Using the Vista Command Shell

Command-line tips specific to Windows Vista are given.
For the most part, the features of the command line are the same in Vista as they are in Windows XP but there are some differences. (The Vista version is 6.0 whereas the XP version is 5.1.) Here are some tips that apply only to Vista.
Run as administrator in Vista
The Windows Vista operating system has a security feature called User Account Control that limits the privileges of users by default. Since the command line is usually involved with administrative tasks, you'll often want to run as an administrator. This can be done each time by right-clicking the icon for the command prompt and choosing "Run as" from the context menu . A more convenient way is to set the command prompt to run with administrator privileges by default. Right-click the command prompt shortcut icon and choose "Properties" from the context menu. Click the "Advanced" button and put a check by "Run as administrator". Click "OK". Note that you will still get the UAC message when you open the command prompt.
Another way to run the command prompt as administrator is to enter "cmd" in Start Search and then use the keyboard combination Ctrl+Shift+ Enter.
"Open Command Window Here" in Vista
It is now easy to open a command prompt referenced to a folder of your choice in Vista. If the Shift key is held down while right-clicking a folder, the context menu will contain an entry, "Open Command Window Here". Selecting this entry will open a command prompt with the chosen folder as the reference point for commands.
Open command window with administrator privileges anywhere
The "Run as administrator" option mentioned above always opens with \Windows\System 32\ as the working directory. To open a command console with administrator privileges in any directory of choice, you can add a command to the right-click context menu. The INF file to make the appropriate Registry edit can be downloaded here. It is from the PowerToy utility described at this link.
Send command output to the Windows clipboard with clip.exe
Vista comes with a command-line utility clip.exe that can be used to redirect or pipe the output of another command to the Windows clipboard. The command uses a "pipe" and has the form: somecommand clipFor example, to send a directory listing to the clipboard, the command is: dir clip
Place the contents of a text file into the Windows clipboard with clip.exe
The utility clip.exe can also be used to read a text file and place its contents in the Windows clipboard. The command has the form: clip < somefile.txt
The batch file command called "choice" is back in Vista
Oldtimers will remember that DOS had a command for batch files called "choice" that allowed for some limited user interaction. The command was then removed from 32-bit command shells because the "set /p" option gave equivalent or better functionality. However, "choice" is back in Vista in a new form. Enter "choice /?" in a Vista command prompt for details about its features.
Use the "choice" command to make a Vista batch file wait
One useful application of the "choice" command is to make a batch file pause for a specified period of time. The statement has the form: choice /T n /D y > nul The switch "/T n" specifies a wait period of n seconds. The switch "/D y" creates a default choice of "yes". To suppress the unwanted text output of the command, it is redirected to the null device (nul).
Use the "timeout" command to make a Vista batch file wait
Another new command in in Vista is "timeout". It will cause the command processor to wait for a specified number of seconds or until a key is pressed. The format is timeout /T n where n is the number of seconds to wait. To make the command ignore any key presses, the switch /nobreak can be added: timeout /T n /nobreak Because the command gives output listing the time remaining, it may be necessary to use a redirect to nul. timeout /T n > nul
Switch added to "Dir" to enable viewing Alternate Data Streams
NTFS files can have added information in "streams" or "forks". These added items are normally hidden from access by most Windows functions such as Explorer. In Vista a switch /R has been added to the "dir" command that allows alternate data streams to be listed.
Enable the built-in master administrator account on the log-in screen
Vista contains a master administrator account but it is not normally visible on the log-in screen. To enable it, open a command window with administrator privileges and use the command net user administrator /active:yes (Make sure that you assign a password to the account.) To remove the account from the log-in screen, use the command net user administrator /active:no
Reduce the space used by System Restore
System Restore can use up to 15% of a hard drive for its backup files (shadow storage). As hard drives get ever bigger, that becomes a lot of space. The command "vssadmin" can be used to administer settings for System Restore. To control the space allocation, open a command prompt with administrator privileges and enter vssadmin Resize ShadowStorage /For=C: /On=C: /Maxsize=[n] For [n] enter the desired size in MB or GB. The units must be stated: for example, "Maxsize=500MB" or "Maxsize=2GB". The example is for the C: drive. WARNING! This will delete all your old Restore Points!
Increase the file system memory cache
If you tend to open and close a lot of files, you may be able to increase performance by creating a larger value for a special cache setting with the file system utility command fsutil behavior set memoryusage 2According to Microsoft, this increases something called the "paged pool" memory. Do not use if you are already consuming large amounts of system memory with other activities. If performance after the change is unsatisfactory, undo it with the commandfsutil behavior set memoryusage 1These commands require administrator privileges. The commands change a Registry setting and take effect after a reboot.
Use "takeown" to access certain files
Vista protects many system files for security reasons and even an administrator is not allowed to access them. If you are denied access to a file while in an administrator account, you can use the command line tool "takeown.exe" to reassign ownership. You will need to run the command from a command prompt with administrator privileges. The syntax is takeown /f some_file [/a] [/r]The specified filename can contain wildcards. You can also specify a folder. The optional switch "/a" transfers ownership to the administrators group. If omitted, the default is to transfer ownership to the present user account. The switch "/r" recurses subdirectories. Although this command assigns ownership, it does not give control rights. Thus if you wish to modify a system file (often not a good idea) you will probably have also to apply the "icacls" command discussed next.
Obtain control rights to a file with "icacls"
(Icacls.exe supersedes the "cacls" command of Windows XP. The older command is still available, however.) This command has a rather complex set of options. They can be displayed by entering "icacls /?" in a command prompt. One example is the command to grant full access rights to an account named user:icacls file_name /grant user:F
Clean up Vista SP1 files
When you install Vista service pack 1, a facility for uninstalling it is also created. If you have SP1 installed for a while and are satisfied that you will keep it, you can remove the uninstall files and free up almost a GB of disk space. To remove the backup files, use the command VSP1CLN.EXE (I have used caps to make the difference between "one" and "ell" clear but case doesn't matter.) Administrator privileges are required. After running this command, you will be unable to uninstall Vista SP1 so be sure you really want to keep it.
Using drag and drop- not
The useful capability to drag commands and drop them into a command prompt that was present in past versions of Windows does not work in Vista. (However, it has been restored in Windows 7.)

Managing Windows XP Programs: Tskill and Taskkill

Windows XP comes with several tools for ending programs or processes from the command line. The features and application of Taskkill and Tskill are discussed.
Sometimes it is desirable to end a program or a process from the command line. The process may be hung or not responding or it may be desirable to have a script for ending it. Both the Home and Professional version of Windows XP come with the tool Tskill . In addition, XP Professional has the more powerful tool Taskkill. Although the graphical utility Task Manager can be used to terminate programs that are hung up, the command line can be faster and easier to use. Also, there may be situations where it is convenient to have a batch file that can be run as a script. In addition, Taskkill is capable of sophisticated filters
TskillThe syntax for the command is TSKILL processid processname [/SERVER:servername] [/ID:sessionid /A] [/V] The meaning of the various parameters is given in Table I.
Table I. Parameters for the command Tskill
Parameter
Description
processid
PID for process to be terminated. Use only if processname is not used
processname
Process name to be terminated. Wildcards can be used here . Do not use if PID is used
/SERVER:servername
Server containing processID (default is current). Usually not needed on home PCs
/ID:sessionid
End process running under the specified session. Often not needed on home PCs
/A
End process running under ALL sessions (administrator privileges required)
/V
Display information about actions being performed
An example of a simple command that would end Notepad would be tskill notepad Another example is ending all the Microsoft documents that you have open tskill winword All open Word documents will be closed but the contents will not be saved so make sure to save important work. An administrator can close processes that might be running in sessions started by other users. The command tskill winword /a will close everybody's open Word documents.
It may not always be obvious what process name to use for a program. Usually the name of the program executable file (minus the EXE extension) will work. One way is to use Tasklist to find the PID and use that. Another is to use Task Manager to find the process associated with a program. (Of course, Task Manager itself can be used to terminate a program.).
Taskkill
A tool with more options is provided by Taskkill. The command syntax is TASKKILL [/S system [/U username [/P[password]]]]{ [/FI filter] [/PID processid /IM imagename] } [/F] [/T] The various parameters are described in Table II.
Table II. Parameters for Taskkill command
Parameter
Description
/S system
Specifies the remote system to connect to. Not needed for most home PCs
/U username
User context under which the command should execute. Often not needed on home PCs
/P password
Password for username
/FI filter
Displays a set of tasks that match criteria specified by the filter
/PID process id
Specifies the PID of the process that has to be terminated. Not used when image name is given in the command
/IM imagename
Specifies the image name of the process that has to be terminated. Wildcard '*' can be used to specify all image names. Not used if PID is given in the command
/F
Forces the termination of all processes
/T
Tree kill: terminates the specified process and any child processes which were started by it
Parameters like the image name or the PID may not be immediately obvious and Tasklist can be used to obtain them. Taskkill has more options than Tskill and is accordingly more complicated to use. For example, the simple command "Taskkill notepad" won't work. First of all the image name is "notepad.exe" and not the program name "notepad". Also, generally you will have to use the forcing switch. The command to close notepad would be taskkill /im notepad.exe /f Another example is to close down several programs at once.taskkill /f /im notepad.exe /im mspaint.exe The Microsoft literature is not consistent about whether the /f switch goes before or after the image name but it doesn't seem to matter.
Filtering Taskkill output
Taskkill becomes especially powerful when filters are used with the switch "/fi". Various rules can be formed by using the comparison operators shown in Table III.
Table III. Comparison operators for filters
Operator
Description
eq
Equals
ne
Does not equal
gt
Greater than. Only used with numeric values
lt
Less than. Only used with numeric values
ge
Greater than or equal to. Only used with numeric values
le
Less than or equal to. Only used with numeric values
Table IV shows the variables that can be used in a filter.
Table IV. Filter operators and allowed values
Parameter
Valid operators
Valid values
ImageName
eq, ne
Any valid string
PID
eq, ne, gt, lt, ge, le
Any valid positive integer
MemUsage
eq, ne, gt, lt, ge, le
Any valid positive integer in kilobytes
CPUTime
eq, ne, gt, lt, ge, le
CPU time in the format of hh:mm:ss.
Session
eq, ne, gt, lt, ge, le
Session number
Status
eq, ne
Running, Not Responding
Username
eq, ne
Any valid user name (includes SYSTEM, LOCAL SERVICE , NETWORK SERVICE)
WindowTitle
eq, ne
Any valid string
Services
eq, ne
Service name
Modules
eq, ne
DLL name
Examples of using filters in TaskkillWith filters, you can impose some specific set of conditions that must be met. Filters give Taskkill considerable versatility and allow you to fine-tune the target..Some examples are given below. Note that a specific image name or PID does not have to be included when using filters.
Forcefully shut down all the processes that are not responding. Can be used to make a little batch file to shut down hung or frozen programs.
taskkill /f /fi "status eq not responding"
Forcefully shut down all programs using a specific DLL file named "some.dll". This should be used with care but one application might be to stop processes thought to be associated with a DLL from spyware or a Trojan. Use Tasklist to see what processes are using a given DLL.
taskkill /f /fi "modules eq some.dll"
Close down all programs using large amounts of memory, say 40 MB. Use with care.
taskkill /f /fi "memusage gt 40000"
Close down programs using more than 40 MB of memory but not Windows Explorer
taskkill /f /fi "imagename ne explorer.exe" /fi "memusage gt 40000"

Tips for Using the Windows Command Prompt

Here's an assortment of tips and tricks for using the Windows command shell.
There are certain little tricks that books on the command prompt don't always tell you. Or, if they do, the description is buried away in a paragraph somewhere. Experienced users of the command line know all about these. However, average users may not and I am going to mention a few useful tips for them. As far as I know the tips work in both Windows XP and Vista except where noted. They may or may not work for older editions of Windows. Tips for Vista only are given on another page.
How to make a blank line in a batch fileSometimes you would like a blank line or two in the output from a batch file. It isn't immediately clear how to do this. Simply entering "echo" doesn't work because that will output the status of command echoing. The trick is to enter echo.Note that "echo" is followed by a period with no space in between.
Force the "echo" command not to parse argumentsThe preceding tip is a special case of a more general method for using the "echo" command. Although the command is used to display text or messages, it can also take certain arguments such as "on" or "off". If you write echo off you will not get a display of the string "off" but will actually be configuring the "echo" command itself. To display the string "off", you would use echo. off In other words, placing a period at the end of "echo" forces the command to simply display whatever follows without checking to see if the string is one of the special cases.
Check if a file existsA special variant of the "If" statement can be used to find out if a file is already present. The statement is if exist somefile somecommand The statement can also test for non-existence of a file with if not exist somefile somecommand
The useful device "nul"
The invisible null device called "nul" has a number of uses. (It's also sometimes called the "bit bucket" or the "black hole".) Anything sent to it disappears. It can be used in statements when you do not want output to be dIsplayed. For example the command somecommand > nul will carry out some command but send whatever is the normal output into oblivion. Sometimes in a batch file you do not want any possible error messages to be displayed. This is done by using somecommand 2> nul
Stopping a runaway commandSometimes you start a command only to find that it is going on and on, spewing out screen after screen of output. Most of the time you can terminate a command by simultaneously pressing the two keys "Ctrl" and "c".
Pausing a scrolling screenIf you have a command with a lot of output,, you can pause the scrolling so that you can read what's on the screen. Use the keyboard combination "Ctrl+s". To resume scrolling, repeat Ctrl+s
Use drag and dropHaving to type the fully qualified path of a file every time it's needed in a command can be tedious and subject to error. Many people are unaware that a file can be dragged from a folder or Windows Explorer view and dropped on an open command window. It saves a lot of typing. (Doesn't work in Vista)
Go up one level above the working directoryAny Unix user knows this one but it's often new to Windows users. To go up to the directory that is one level above the working directory, enter cd .. You can repeat this to go up more levels. It's a little off the subject of the command shell but in the Start-Run line just entering the two periods ".." will also take you up one level from the default working directory (the working directory is normally%USERPROFILE%)
How to change the working directory to a folder on a different drive
If you want to change the working directory for a command window to a folder on a different drive, the command "cd" doesn't work. You have to first enter the drive letter and colon and then enter "cd" and the folder path. However, you can use the switch /d to change the current working directory drive as shown below: cd /d E:\testYou can also make the change with one command entry if you use "pushd" instead of "cd": pushd E:\test
Watch out for spaces in file and folder names
The command shell does not recognize spaces in path names. Any path name with spaces must be enclosed in quotation marks. This problem often crops up in scripts where certain environment variables or input arguments are used. For safety, variables that involve file or folder names should be enclosed in quotes.
Special treatment of variables in "For" statements in batch files
"For" statements are very useful, providing powerful iterative methods. They have the peculiarity, however, of requiring double percent signs for iteration variables in batch files. in other words the syntax in a batch file is:for %%variable In set Do statementIf a "For" loop is run directly from the command line, only a single percent sign is used. The syntax is then: for %variable In set Do statement
Case-sensitive variables in "For" statements
In contrast to Unix systems, Windows is usually not case-sensitive, However, iteration variables in "For" statements are case-dependent. So %A is a different variable from %a.
Pin a command-line shortcut to the Start menu
If you use the command prompt frequently, make it easily accessible. Open Start-All Programs-Accessories and right-click the entry "Command Prompt". Select "Pin to Start menu" from the context menu. Or go to \WINDOWS\system32 and right-click the command shell file cmd.exe and select "Pin to Start menu" from the context menu.
Create a shortcut to a command
If there is a command that you use frequently, you can create a shortcut. The trick is to use the switch /k so that the command prompt stays open. The entry for the shortcut should be cmd /k somecommand.exeIf the command also needs switches, those can added as well. (The general details of making a shortcut are at this page.)
Open Windows Explorer from the command line
To open the current command-line directory in a Windows Explorer window use the command start .To open the directory above the current command-line directory in a Windows Explorer window use the commandstart ..(Windows XP only) To open My Computer in a Windows Explorer window use the commandstart ...
Using the command "Start"
The tip given above is an example of how the "Start" command can be used to invoke an action or a system folder or an URL. For example, simply entering "cookies" in the Run line will open the system folder Internet Cookies in Windows XP (but not in Vista). However, in the command shell, you would need to enter start cookies In Vista, the command has to be modified with the Shell command and would be start shell:cookies Similarly, you can open a program like Microsoft Word with the commandstart winwordYou can also open a Web page in Internet Explorer with a command of the typestart http://somesite.com
Save typing with file-name and folder-name completion (Tab completion)
A very useful feature that can save a lot of typing is the name or path completion function. This feature uses the Tab key to complete file and folder names that you begin typing. For example, type "a" (no quotes) into a command line and then press the Tab key. Windows will complete your typing with the name of an existing file or folder beginning with "a", starting in alphabetic order. Press Tab again and the next possible file or folder will be displayed. In this way, you can cycle through all files and folders existing in your current path that begin with a particular character or group of characters. The keyboard pair Shift + Tab will take you backwards in the list. The tab completion function can be used in more than one place in a command.
Enable QuickEdit mode for the command window
Being able to cut and paste to and from the command window is very handy but it is not enabled by default. I use this feature frequently and I suggest that you enable it for all command windows. The details of how to enable QuickEdit are given on another page. Once QuickEdit is enabled, the contents of the clipboard can be entered into a command prompt by right-clicking in the command window.
Display the Command HistoryThe default setting for the configuration of a command window includes the capability for storing up to 50 previously entered commands. The command history can be displayed by entering the "F7" key.
Use the "sleep" command in Windows XP batch files
Sometimes it is desirable to have a batch file wait a certain amount of time before it carries out the next command. If you download the free Windows 2003 Server tools (described on another page), one of the available tools is sleep.exe, which provides a way to make batch files wait a specified interval. For an interval of n seconds the command is: sleep n
Copy text from the console window
Way back in the days of DOS, it was not uncommon to enter text directly from the command window into a file with the "copy" command. That is less common in Windows but the capability is still there. Output from the command window or console is denoted by CON. (It is not case-sensitve.) To copy text from the command window to a file "sometext.txt", the sequence of statements would be copy con sometext.txtFirst line of your desired textsome more text...^Z The last line indicates the keyboard combination of the Control key and "z" followed by pressing the Enter key. This command terminates the sequence and sends the text to the desired file, which it creates. This particular example places the file in the working directory but other paths can be used.
Tips for the Vista command shell
Windows XP and Vista share many of the same features in the command line. However, as to be expected, there are some differences. Tips that are relevant to Vista only are given on the next page.

Managing Windows XP Programs from the Command Line: Tasklist

Managing Windows XP Programs from the Command Line: Tasklist
Windows XP Professional comes with a powerful command-line tool called Tasklist that provides many details on the programs and processes that are running.
Many will be familiar with the graphical tool Task Manager, which I have discussed elsewhere, and which provides various kinds of information about the applications and processes that are running on a system. There are also several command-line tools that provide similar but even more detailed information. In this article I will discuss the features of the tool called Tasklist (the system file is tasklist.exe). This tool is part of the regular installation of the Professional version of XP but does not come with the Home edition. However, those with the Home version of XP can download Tasklist here. Tasklist can be applied to see how much memory and CPU time running processes are using, what DLL files they rely on, and other information. Thus it can be a very useful troubleshooting tool.
Basic Tasklist command
If all you want to know is what tasks are running, enter TASKLIST into the command line. The output can be redirected to a file if you wish. The default format is a table with several columns of information. An example of a partial console output is shown in the figure below. There are five columns of information. The following list gives the meanings of the various column headings:
Image Name
The name of the process or the executable file running the process.
PID
The process ID. The system assigns a number to each process so it can keep track of it. It is possible to have several processes running with identical names but the PID will be unique. Note that the PID may not be the same each time you open a particular program. You may need the PID to run certain other diagnostic tools and Tasklist is one way to obtain this information.
Session Name
Unless you are on a network, this will read "Console" indicating that the process was started locally. Home PC users can usually ignore this column.
Session#
Each session is assigned a number. Home PC users can usually ignore this column also.
Mem Usage
This gives the very useful information about how much memory (in KB) that a process was using at the time Tasklist was run.
Additional columns will be displayed in the so-called "verbose" mode that is obtained with the switch /v. These columns are:
Status
Gives the current status of the process as "Running", "Not Responding", or "Unknown". Useful for finding hung processes. Unknown status may refer to a normal process but Not Responding indicates a process that should be stopped.
User Name
User account under which the process is running, Windows itself will be running many processes and the various system accounts SYSTEM, LOCAL SERVICE , or NETWORK SERVICE. will appear, coupled with the local domain name NT AUTHORITY.
CPU Time
The total amount of CPU cycle time used by the process since its start. This can be a big number if you never turn off the computer.
Window Title
Windows display name of the process if it exists. Can sometimes help identify what program is involved.
More advanced options for Tasklist
There are many more options and these are provided by switches. The full syntax is: TASKLIST [/S system [/U username [/P [password]]]] [/M [module] /SVC /V] [/FI filter] [/FO format] [/NH] Upper case has been used for clarity but the command is not case-sensitive. Table I describes the various parameters.
Table I. Parameters for TASKLIST
Parameter
Description
/S system
Specifies the remote system to connect to. Not needed for local computer
/U username
Specifies the user context. Not needed for local computer
/P [password]
Specifies the password for the given user context (if necessary).
/M [module]
Lists all tasks that have DLL modules loaded in them that match the given pattern name. If the module name is not specified, displays all modules loaded by each task.
/SVC
Displays services in each process.
/V
Specifies that the verbose information is to be displayed.
/FI filter
Displays a set of tasks that match a given criteria specified by the filter.
/FO format
Specifies the output format. Valid values: "TABLE", "LIST", "CSV".
/NH
Specifies that the "Column Header" should not be displayed in the output. Valid only for "TABLE" and "CSV" formats.
These additional parameters enable Tasklist to provide very detailed information about the system. Some examples will be shown in the next sections.
Find which Services use a processIt can be very useful to know the relationship between a process and the services that are running on a system (for a discussion of services see this page.) To obtain a table relating Image Name, PID, and Services use the command tasklist /svc >list.txt Here I have shown the redirect to a file to illustrate creating a text record. One application of this command is for diagnosing problems with a service by monitoring the memory usage and other properties of the processes associated with the service.
Find which DLL files are used by a processProcesses can be using many different DLL files by calling on various procedures from their libraries. It is not uncommon for a problem to arise because a DLL is corrupted or is the wrong version. To find which DLLs are used by each process use the commandtasklist /mThis will return a table relating Image Name, PID, and Modules. "Modules" here indicates DLLs. The table may have quite a few entries and the list can be limited to a specific DLL by using its name in the command. For example, to see only the processes that use oleaut32.dll, entertasklist /m oleaut32.dll
Filtering Tasklist output
The output can be narrowed down to specific parameters by using filters and the switch /FI. There are a number of comparison operators and these are given in Table II. Not all operators can be used with every parameter and allowed values are shown for the most useful parameters in Table III.
Table II. Comparison operators for filters
Operator
Description
eq
Equals
ne
Does not equal
gt
Greater than. Only used with numeric values
lt
Less than. Only used with numeric values
ge
Greater than or equal to. Only used with numeric values
le
Less than or equal to. Only used with numeric values
Table III. Filter operators and allowed values
Parameter
Valid operators
Valid values
ImageName
eq, ne
Any valid string
PID
eq, ne, gt, lt, ge, le
Any valid positive integer
MemUsage
eq, ne, gt, lt, ge, le
Any valid positive integer in kilobytes
Status
eq, ne
Running, Not Responding, Unknown
Username
eq, ne
Any valid user name (includes SYSTEM, LOCAL SERVICE , NETWORK SERVICE)
WindowTitle
eq, ne
Any valid string
An example of using a filter is a command to find processes that are not responding. The command would be tasklist /fi "status eq not responding" Another example is to find processes using a lot of memory, say more than 40 MB. The command is tasklist /fi "memusage gt 40000"
A final example shows how to clarify the multiple entries for the process "svchost.exe" that occur. (Each has a different PID.) Service Host (svchost.exe) is a basic piece of the Windows XP OS that is involved with many low-level system services. These are placed in several service groups, all running under the generic service name "svchost.exe" .(See the discussion here.) To see which services are associated with each instance of svchost.exe, use the command tasklist /svc /fi "imagename eq svchost.exe"
More infornation on Tasklist is at this Microsoft site.

Windows XP SP2 Support Tools

Windows systems come with numerous command-line tools. There are also others that can be downloaded and installed. One group is called support tools and a number of these are listed here. The tools are primarily for system administration but some can also be applied to diagnosing and resolving computer problems in PCs in the home.
The list below omits some of the more specialized tools, such as those for Active Directory. A complete list is here along with the free download. These tools are in addition to the large number of command-line utilities that are part of the default installation of Windows XP Professional. These additional tools require their own installation . (Not available for 64-bit Windows XP.)
A Selection of Windows XP Command-Line Support Tools
acldiag.exe- manages access control lists
activate.exe- Windows product activation
apmstat.exe- provides status information on Advanced Power Management (APM) features.
bindiff.exe- shows the differences between two binary files
bitsadmin.exe- manages the Background Intelligent Transfer Service
browstat.exe- a general purpose character-based browser diagnostic tool
cabarc.exe- allows users to create, query and extract Windows cabinet (CAB) files.
depends.exe- provides way to determine which DLLs an application depends on ( also known as "Dependency Walker")
dhcploc.exe- displays the DHCP servers active on your subnet
diruse.exe- displays directory size information for NTFS volumes
dmdiag.exe- displays system state and configuration information describing disk storage.
dupfinder.exe- duplicate file finder
efsinfo.exe- displays information about files that are encrypted with Encrypting File System (EFS) on NTFS partitions.
extract.exe- a utility that allows you to extract all files or specific files contained within a cabinet (.cab) file
filever.exe- displays information on the versions of executable files
ipseccmd.exe- configures Internet Protocol Security (IPSec) policies
memsnap.exe- takes a snapshot of the memory resources being consumed by all running processes and writes this information to a log file
msicuu.exe- Windows Installer Clean Up Utility
msizap.exe- removes either all Windows Installer information for a product or all products installed on a computer
netcap.exe- monitors packets on a LAN and writes the information to a log file
netdiag.exe- tests the network connectivity
netset.exe- used to add, remove, or change the network configuration
pfmon.exe- displays the faults that occur while executing a process
pstat.exe- gives you information about the processes and drivers that are currently running on your computer.
pviewer.exe- process viewer
setx.exe- sets environment variables
showaccs.exe- enables users to examine the access control lists (ACLs)
timezone.exe- Daylight Saving Time Update Utility
whoami.exe- displays the user name and security identifier (SID)
windiff.exe- shows the differences between specified ASCII text files, or folders containing ASCII text files
xcacls.exe- used to set all file-system security options that are accessible in Windows Explorer from the command line

Managing Windows XP Services with the Service Controller Command SC

A suite of command line networking tools called Netsh that comes with its own shell or interface is contained in a number of Windows operating systems and is discussed here.
Introduction to Netsh
As more and more home users set up networks, they are finding themselves to be de facto system administrators. Home networks are very nice but they require a certain amount of care and feeding. Fortunately, Windows XP comes with a large assortment of command-line tools that can help maintain your network. Although many are specialized and of interest only to administrators of large corporate setups, some tools can be quite helpful to the home user as well.
Many may find that the basic tools like ping, ipconfig, and netstat, which are discussed on another page, are all that they care to deal with but the more adventurous can take advantage of a complete suite of powerful tools called Netsh. This suite is invoked from the standard command-line but has it has own interface or shell with a large number of sub-commands. I will try to focus on the features of Netsh that I think can be helpful to the home user. The whole suite has many applications and those who want more details can go to this Microsoft reference.
The Network Services shell is opened by entering netsh into a regular command prompt. The shell has a hierarchical structure with some sub-shells that Microsoft calls "contexts". From the user's point of view, however, all that this means is that commands are entered as a sequence of terms. The following sections discuss the "contexts" of most use to the home user.
The "netsh diag" context
The diagnostic context "diag" contains useful tools for checking out a network and testing various components and functions. Table I shows the contexts and sub-commands of most interest to this discussion. A complete list and many details are given at this Microsoft reference.
Table I. Some sub-shells (contexts) and commands for Netsh diag
Context
Sub-context
Commands
diag
connect- Establishes, verifies, and then drops a connection
iphost, mail, news
ping- Verifies connectivity
adapter, iphost, mail, news
show- Lists network components and settings
all, client, ip, mail, modem
gui- Starts the network diagnostics tool in Help and Support Center.
Graphical user interface
This group of commands provides ways to test some of the most common functions of interest to home users. For example, you can test if your email server is working or check your email settings by the command netsh diag connect mail (Note that this may not work for email clients like AOL.). Another example is to list important settings withnetsh diag show all
The graphical user interface
One way to simplify diagnostic tasks is to use the Help Center interface that can be invoked by entering netsh diag gui With this interface, you can carry out a number of diagnostic tests with one operation. Figure 1 shows the available functions.
Figure 1. Settings for GUI function of Netsh diag
The "netsh interface ip" context
This context is another with functions that might interest a home user. It provides a way to add, delete, modify, and display various IP addresses and TCP/IP settings. Table II lists several functions. More detail and additional functions are discussed in this Microsoft reference. An example of its use is to display TCP/IP settings with the command netsh interface ip show configThis can also be written netsh int ip show config
Table II. Some commands for "netsh interface ip"
Context
Sub-context
Function
interface iporint ip
set address
Configures an IP address and a default gateway on a specified interface
show address
Displays address for specified interface
Reset Internet Protocol (TCP/IP)
Another example of using the Netsh Internet Ip context is resetting TCP/IP. For several reasons, including infestation from spyware, these settings might get corrupted. Netsh contains a command that will reset the TCP/IP stack to the original settings that existed when the operating system was installed. These settings may not be the most up-to-date for your system but they will allow you to reconfigure after a spyware invasion or other problem. The command to reset TCP/IP is netsh int ip reset {logfile} Note that you must include the name of a file where a log of the actions will be placed. Thus, if the log file is C:\tcplog.txt, the command is netsh int ip reset C:\tcplog.txt A detailed description of reinstalling TCP/IP is given at this Microsoft reference. Also, see the Winsock section below.
The "netsh winsock" context
Service pack 2 for Windows XP includes some additions to the Netsh suite. These are discussed here and include a new tool for repairing the Windows network socket or "winsock". Uninstalling spyware or poorly written applications can corrupt the winsock settings and result in loss of network connectivity. There are two commands for managing the settings. To display a list of various installed services (LSP, BSP, NSP) use netsh winsock show catalog This list may not be too meaningful for the average PC user but it can be helpful for more experienced users. To reset the winsock to the default configuration use netsh winsock reset catalog Note that any installed software that uses Internet connections may be partially disabled by this action and have to be reinstalled. This would include most software that updates itself and anti-virus programs that use proxy servers. Therefore, this command should only be used for cases where the degree of corruption makes it necessary. See this reference for some alternative methods.
Netsh Firewall Helper in Windows XP SP2
Microsoft changed the way the firewall in Windows XP works when it issued service pack 2. It also added capability to Netsh for extensive configuring of the firewall with a new context "netsh firewall" that Microsoft calls the Firewall Helper. Its use in troubleshooting firewall problems in SP2 is extensively discussed in this knowledge base article. With the Firewall Helper Microsoft says you can now
• Configure the default state of Windows Firewall. (Options include Off, On, and On with no exceptions.) • Configure the ports that must be open. • Configure the ports to enable global access or to restrict access to the local subnet. • Set ports to be open on all interfaces or only on a specific interface. • Configure the logging options. • Configure the Internet Control Message Protocol (ICMP) handling options. • Add or remove programs from the exceptions list
The number of possible commands is quite large but two main sub-contexts are netsh firewall set and netsh firewall show An extensive list of commands is in the knowledge base article previously mentioned.

Explaining DNS Concepts - DNS Servers-DNS Queries-DNS Records

3 types of DNS queries— recursive, iterative, and non-recursive 3 types of DNS servers— DNS Resolver, DNS Root Server and Authoritative Name...