Windows XP/2003/Vista/Win7/Server 2008 command line utilities (IMHO) are neglected by most IT Professionals, this is mostly due to everyone being used to the GUI. *nix/BSD people live in the command shell. Listed below are some old trusty commands from the DOS days which still work today in Vista together with some new updated tools.
Useful commands: (see syntax full more details)
FC – compares files
fc file1 file2 ; Compares file1 to file2
GETMAC – get the mac address of the computers NIC or adapter
getmac /v ; provides the MAC address in verbose mode
getmac /S computer1 /FO list /v ; Provides the MAC address on a remote computer named ; computer1 and formats the output in a list verbosely
SFC – system file checker, scans all system files and replaces incorrect versions
sfc /scannow ; Scans all protected system files immediately
SUBST – Associates a path with a drive letter.
subst u: c:myfoldermysubfolderdata ; Drive letter U: will now list the contents of ; c:myfoldermysubfolderdata
SYSTEMINFO – Displays operating system configuration information.
systeminfo /FO list ; Displays the information in a list format
systeminfo /FO list > c:tempmysys.txt ; Pipes the information out to a text file names ; mysys.txt
TASKLIST – Displays a list of currently running processes on either a local or remote machine.
tasklist /FO table /V ; Lists all the tasks running and formats it into a table view
TASKKILL – Terminate tasks by PID or image name.
taskkill /IM notepad.exe ; Will terminate notepad.exe
taskkill /PID 3493 ; Will terminate Process ID 3493 which could be calc.exe use tasklist
TREE – Displays the folder structure of a drive or path.
tree d:myfolders /F ; Displays the folder structure and files within
NETSH commands: (deserves it’s own section)
NETSH is one of the most powerful command line utilites! The only thing with greater power and flexibility is the new PowerShell. NETSH as far as I know started with Windows XP and Server 2003, however I’ve noticed that in Vista/Longhorn some commands have been removed and others added. Here are just a few examples of what I use it for:
netsh firewall show state ; Displays the current state of the Windows firewall
netsh interface ip show config ; The same as IPCONFIG in Vista it’s ipv4 instead of ip
netsh -c interface dump > c:lanconfig.txt ; Dumps the lan config including IP, GW, DNS
netsh -f c:lanconfig.txt ; Imports the configuration from above. Handy if you need to ; change IP settings on a static network without DHCP etc.
Create a script with netsh commands to change your IP and firewall settings:
This script will change the IP, Gateway and DNS settings and turn off the firewall for testing.
ECHO Setting IP Address Please Wait…
netsh int ip set address “Local Area Connection” static 10.10.0.20 255.255.255.0 10.10.0.254 1
ECHO Setting DNS Please Wait…
netsh int ip set dns “Local Area Connection” static 10.10.0.2
ECHO All addresses Set…
ECHO Now I’m going to turn off the Firewall for testing…
netsh firewall set opmode disable
Echo Firewall is off… BE CAREFUL!!!
This script will change the NIC settings back to DHCP and turn the firewall back on.
ECHO Resetting IP Address to DHCP Please Wait…
netsh int ip set address “Local Area Connection” dhcp
ECHO resetting WINS to DHCP Please Wait…
netsh int ip set wins “Local Area Connection” dhcp
ECHO resetting DNS to DHCP Please Wait…
netsh int ip set dns “Local Area Connection” dhcp
ECHO All addresses reset to DHCP
ECHO Turning on Firewall…
netsh firewall set opmode mode = enable exceptions = disable
ECHO Firewall ON, we are ready for normal operation.. Bye!