Recipe 6.2. Suspending a ProcessProblemYou want to suspend a process from running. This is helpful if you want to temporarily stop an application from running, perhaps due to high CPU consumption, but you don't want to kill it. This can give you an opportunity to launch further diagnostic utilities to troubleshoot the process. SolutionUsing a graphical user interfaceOpen the Sysinternals Process Explorer tool (procexp.exe). To suspend a process, right-click on the target process and select Suspend. To resume a process, right-click on the target process and select Resume. Using a command-line interfaceThe following command suspends a process: > pssuspend <PID> Replace <PID> with the process ID of the target process. The following command resumes a suspended process: > pssuspend -r <PID> Using VBScriptCurrently, no scripting API supports suspending processes. However, you can use the SuspendThread and ResumeThread functions that are defined in kernel.lib if you are using a high-level language such as Visual Basic or C++. DiscussionApplications are much better behaved these days than they were a few years ago, but that still doesn't mean you won't see one from time to time peg the CPU on a system and render it virtually useless. If this happens on a remote system, it can be difficult to even use Terminal Services to access the machine. So what can you do? Well, if you can find out which process is causing the problemperhaps by using one of the methods in Recipe 6.4you can use pssuspend to remotely suspend it. You can also specify alternate credentials using the -u (user) and -p (password) options. If you specify -u without -p, it will prompt you to enter the password (this is the more secure way to do it). Here is an example command line that does this: > pssuspend \\jamison -u rallen notepad.exe See AlsoRecipe 6.4 |