Computer Voodoo logo

networking | administration | environmental variables | useful real-world examples

using the command line

Typing the command followed by a space and /? will typically display brief help on the command.

Anything listed with <angle brackets> is a variable supplied by the user.

networking

ipconfig /all
lists all network adapters and their current status
netsh interface ip set address "<interface name>" static <ip address> <netmask> <default gateway> <metric>
netsh interface ip set address "Local Area Connection" static 192.168.5.16 255.255.255.0 192.168.5.1 1
Changes the IP address to 192.168.5.16/24 with a gateway of 192.168.5.1
The lower the metric value the higher the rank.
netsh interface ip set address "Local Area Connection" source=dhcp
Sets IP using DHCP
net view \\<server_name>
view shares on computer named <server_name>
net view /DOMAIN:<domain_name>
view shares on a domain
net use <drive_letter>: \\<server_name>\<directory> /user:<user_name>
map a share to a drive letter using the <user_name> as the login name
net use <drive_letter>: /delete
remove a mapped drive
net use <port>: \\<server_name>\<printer_name>
setup a connection to a shared printer on <server_name> using a particular port (LPT1, COM2, etc)
netsh
When you want networking information you can use the Network Shell.
netsh diag show all will display information about the current network configuration.
netstat
List active connections on your computer.
nslookup <domain_name>
Performs a DNS lookup on domain_name to determine its IP address.
ping <domain_name_or_IP>
Similar to a SONAR ping with submarines, ping will send out a signal to a target and report how long the round trip takes.
tracert <domain_name_or_IP>
Runs a traceroute command to show the hops the connection takes between your computer and the destination.

administration

sc delete <ServiceName>
Deletes the service <ServiceName>
If the service name listed in services.msc has spaces, enclose it in quotes.
tasklist
Prints a rundown of the processes that are currently running on the system. Add /SVC to list services within each process.
taskkill
Kills off a process that will not respond.
expand <source> <destination>
Sometimes you need files tucked away in cabinet (.CAB) files.
-r renames the destination filenames based upon the source filename.
-D displays the list of files contained within the .CAB
-F:<files> decompresses one or more files from the .CAB.
systeminfo | findstr /i boot
Find the time the system was last booted.
This first scans the system configuration then has findstr locate the word boot amongst the info.

environmental variables

Type the echo command before the variable to display the contents of the variable (e.g. echo %userprofile%).

%SystemRoot%
The Windows directory. Either C:\Windows or C:\WINNT
%UserProfile%
C:\Documents and Settings\{UserName} or C:\Users\{UserName}
%UserName%
Take a guess.

useful real-world examples

Send a listing of a directory/folder into a text file

dir C:\temp /s > C:\directory_list.txt

dir
This command lists files.
C:\temp
The location to look through. Tells DIR to look in the TEMP folder which is located on the C: drive
/s
An option to tell the DIR command to look through all subdirectories/subfolders contained in TEMP.
>
Sends the output of the DIR command to another location to be named in the next step.
C:\directory_list.txt
Tells the output command from above to send the data into text file named directory_list.txt on the C: drive.

output the list of programs installed in Windows

wmic /output:C:\install_list.txt product get name,version

wmic
Windows Management Instrumentation Command-line
/output:C:\install_list.txt
Tells WMIC to output the resulting information to a text file name install_list.txt in the C: drive root directory.
product get name,version
Tells WMIC to look at the listing of installed programs and retrieve (GET) their names and version numbers.

Shutdown your computer without installing updates

shutdown /s /f /t 0

shutdown
The main command. The switches tell whether to shutdown, restart, etc.
/s
tells the computer to shutdown
/f
forces applications to close
/t 0
sets the timeout period in seconds. 0 shuts down immediately. 10 would wait ten seconds before shutting down.

send output from the command line to the clipboard

ipconfig | clip

ipconfig
ipconfig will output all the networking info
|
| is called a pipe. This tells Windows to send the output from the first command (ipconfig) to the command following the pipe.
clip
clip sends data to the clipboard

If you want to blank out the clipboard: echo. | clip