09.02.2014 Views

Windows sysinternals

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 6 Pstools 181<br />

If the target is a multiprocessor system, you can specify that the threads of the target<br />

process be scheduled only on specific CPUs. Add the –a option followed by the list of logical<br />

CPUs separated by commas (where 1 is the lowest-numbered CPU). For example, to run the<br />

process only on CPU 3, use the following:<br />

psexec -a 3 app.exe<br />

To run the target process on CPUs 2, 3 and 4, use this command line:<br />

psexec -a 2,3,4 app.exe<br />

Remote Connectivity Options<br />

If the program you want to run on a remote system is not installed on that system, PsExec<br />

can copy it from the local file system to the remote computer’s system32 folder, run it from<br />

that location, and then delete the program after it has finished execution. You can make the<br />

copy conditional on a newer version not already being present on the remote system. When<br />

you specify the –c option, the “program” on the PsExec command line specifies a file path<br />

relative to the local computer; that file is copied to the system32 folder of the remote system.<br />

Note, though, that this option copies only that one file; it does not copy any dependent DLLs<br />

or other files.<br />

Using the –c option by itself, PsExec does not perform the file copy if the file already exists in<br />

the target location. Adding the –f option forces the file copy, even overwriting a file marked<br />

as read-only, hidden, or system. The –v option checks the file versions and time stamps,<br />

copying only if the local copy has a higher version and a newer time stamp, but starting the<br />

remote process in either case.<br />

When trying to establish a connection with a remote system that is offline, is very busy, or<br />

has some other connectivity problems, PsExec uses the default system timeouts for each<br />

of the network operations required. To select a shorter timeout period, use the –n option<br />

followed by the maximum number of seconds that PsExec should allow for each remote<br />

connection. For example, to limit the amount of time spent trying to connect to a series of<br />

remote systems to 10 seconds each, use the following:<br />

psexec @computers.txt -n 10 app.exe<br />

Runtime Environment Options<br />

PsExec offers several command-line options to control the runtime environment of the<br />

target process. These options include the ability to run the process in the System account or<br />

in a reduced-privileged mode, whether to run interactively and in which interactive session,<br />

whether to load the account’s profile on the target system, and the ability to set the initial<br />

working directory of the target process.<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!