skip navigation

www.Hilands.com


Content:: Windows Command Line

A quick reference of commands I use for Windows XP and Windows 2003 Server

Flushing Windows DNS Cache
A standard windows system will run a service called "DNS Client", the Windows DNS Client acts as a DNS caching service where the domain name and IP address translation is stored locally on the system. This is a great idea and has a huge potential to reduce network traffic caused by DNS chatter. If you make changes to you DNS and require the new records or if your connection drops while using a Dynamic DNS service like dyndns you may need to clear this local stored cache.

The ipconfig command is used to control the majority of your windows network configurations and settings, it is also used to flush the DNS with the command below.

# ipconfig /flushdns





Event Viewer Window
The logs for Windows are viewable with a simple to use interface. This interface can be opened by going to your control panel, administrative tools. I find it alot easier to start it from the run command Start, Run or Windows Key + R and typing in # eventvwr.exe
You can also use this command to open the event viewer on remote systems # eventvwr.exe 192.168.0.2





Force the windows autoupdate
This sometimes does not seem to work.... or it may take some time # wuauclt.exe /detectnow to reauth with WSUS # wuauclt.exe /resetauthorization /detectnow




Listing Tasks
The most common way to view processes running on your computer will be with the windows graphical taskmanager. This application can be opened via the command prompt or the run menu with the following command taskmgr.exe However sometimes we may need more information about the system processes running than that are available in the task manager. Or something as simple as having the ability to copy the list of running processes to a text file so we have something to compare it to later. If you would like more information about the task manager view this Taskmanager how to

To display a list of processes via the command line we can use the built in tool tasklist. # tasklist * This program is not standard with Windows XP Home Edition. Use the following link to download the tasklist program http://www.computerhope.com/download/winxp.htm
The output should be the following
Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0 Services                   0         24 K
System                           4 Services                   0        820 K
cmd.exe                       3140 Console                    1      3,192 K
We can also send the output to a text document # tasklist > tasks.txt This will send the output from tasklist to the file "tasks.txt", remember your current location is where the new file will be created!

We can also get an alphabatized list by piping the output through sort. We will also add the no header switch of "/nh" # tasklist /nh |sort




Killing a task
We can also kill processes from the command line, this is especially useful when the task manager has been disabled by your virus/malware application.
We will use the "taskkill" command with the process id and image name switches. For our example we will be killing the command prompt window shown in our tasklist output above.

We will use the name of the Image or process to kill the command prompt first. # taskkill /im cmd.exe There may be times where you have multiple applications with the same name. In that case you may want to use the Process Identifier to point out the specific application you would like to terminate. # taskkill /pid 3140
You can use the /? switch for more information. Due note that the switches are not case sensitive. # taskkill /? tasklist reference :
http://technet.microsoft.com/en-us/library/bb491010.aspx
http://commandwindows.com/tasklist.htm





Other Windows Commands to write stuff about
# netdiag
# dcdiag
# gpresult
# gpupdate (replaced w2k command secedit /refreshpolicy
# gpupdate /force
Last Modified: 2010-08-20