Tuesday, March 19, 2013

PsExec and running CMD remotely / on remote PCs


PsExec at http://technet.microsoft.com/en-us/sysinternals/bb897553

This little application may not work in all situations, but it's a time saver when it does.

I needed to verify some IP configuration, run ipconfig, nslookup, ping, etc. on a PC that was miles away and where the user was not going to be cooperative.  The basic challenge was to execute a command prompt on a remote PC without installing software there or interrupting the user.

PsExec is a little executable that allows you to run applications on remote machines without installing client software.  One very cool option is the ability run interactive command prompts, like cmd.exe or ipconfig without user intervention.  There appear to be limitations re: access to network resources on the target PC, possibly user privileges on the remote and target PC, and maybe some antivirus / anti-malware applications objecting to its usage, so tread carefully.

Here's some CLI options from Microsoft's technet page:

The following command launches an interactive command prompt on \\marklap:

psexec \\marklap cmd

This command executes IpConfig on the remote system with the /all switch, and displays the resulting output locally:

psexec \\marklap ipconfig /all

This command copies the program test.exe to the remote system and executes it interactively:

psexec \\marklap -c test.exe

Specify the full path to a program that is already installed on a remote system if its not on the system's path:

psexec \\marklap c:\bin\test.exe

Run Regedit interactively in the System account to view the contents of the SAM and SECURITY keys::

psexec -i -d -s c:\windows\regedit.exe

To run Internet Explorer as with limited-user privileges use this command:

psexec -l -d "c:\program files\internet explorer\iexplore.exe"

No comments:

Post a Comment