Thursday, May 13, 2004

New Windows XP/2003 command-line utilities

Microsoft rolled a large number of command line tools from the various resource kits into the standard OS. They also renamed/rewrote some tools to do similar but different things. Because of this, some utilities you might be used in the Windows 2000 resource kit/support tools add-ons are are no longer provided. Three big ones no longer included are pulist, tlist, and kill are no longer.

1) Killing processes, You need to use 'taskkill' now. Examples:

Killing pid 1977
    taskkill /PID 1977 /T
Force killing pid 1234
    taskkill /PID 1234 /T /F

2) Listing processes, You need to use "tasklist" now. Running the command by itself gives similar information to "tlist". There is no equivalent, that I am aware of, to a tlist -t. You also can't use tasklist to get the command line for a process. I haven't found another built-in program that will show that information. Examples:

Listing all tasks on the host:
    tasklist
Listing verbose task information for all oracle.exe processes on the host:
    tasklist /v /fi "IMAGENAME eq oracle.exe"

3) Scheduling commands:
There is a builtin command line interface to the enhanced functionality of the scheduled tasks, called "schtasks". It will display the same tasks list as "Scheduled Tasks" in the control panel. In the same way that you can not see scheduled tasks with at on Windows NT/2000, you will not be able to see tasks scheduled with schtasks with at.exe. Examples:

Listing all scheduled tasks:
    schtasks
Listing detailed information about tasks:
    schtasks /query /v
Forcing a backup of a database to run "right now"
    schtasks /run /tn "db_backup.cmd"
Deleting a task called db_backup.cmd
    schtasks /delete /tn "db_backup.cmd"
Creating a new scheduled task to run every day of the week:
    schtasks.exe /create /ru SYSTEM /SC WEEKLY /D MON,TUE,WED,THU,FRI,SAT,SUN /TR C:\Utils\SCRIPTS\.\.\ACCREQ.CMD /ST 18:00 /TN ACCREQ.CMD

No comments: