Monday 5 November 2012

Take a screenshot of a remote computer with psexec and nircmd

What:

psexec, nircmd and Windows

Problem:

Take a screenshot of a remote computer in your network and save it to selected location. Optionally save 20 screenshots every minute in a loop.

Solution:

Download psexec from http://live.sysinternals.com/, download nircmd from http://www.nirsoft.net
psexec.exe \\192.168.1.10 -u "domain\administrator" -p "password" -i -c nircmd.exe savescreenshot "c:\shot.png"
shot.png will be saved on target computer

If you are logged on as administrator then you can skip -u and -p options, you can skip only -p then you will be prompt for a password.
psexec.exe \\192.168.1.10 -u "domain\administrator"  -i -c nircmd.exe savescreenshot "c:\shot.png"
Save 20 screenshots every minute in a loop:
psexec.exe \\192.168.1.10 -u "domain\administrator" -p "password" -i -c nircmd.exe loop 20 60000 savescreenshot "scr~$currdate.MM_dd_yyyy$-~$currtime.HH_mm_ss$.png"

Gain access to remote pc via console (telnet equivalent):
psexec.exe \\192.168.1.10 -u "domain\administrator" -p "password" cmd

10 comments:

  1. I keep getting "nircmd.exe exited on (remote PC's IP) with error code 0."

    I manually copied over nircmd.exe to %WinDir% of the remote PC, but then the command failed with "File already exists."

    What could be the problem? Thanks!

    ReplyDelete
  2. Never mind, figured it out: error code 0 = success

    Important to note that c:\shot.png is saved to the hard drive of the remote PC, and the logged in user must have local admin rights to be able to write to C:

    ReplyDelete
  3. I am glad that you figured it out. Btw. domain\administrator has local admin rights, so there is no problem saving to the C: drive.

    ReplyDelete
  4. I'm getting a black screen, but when I run it locally on remote machine it works fine.

    ReplyDelete
  5. you should use impressionate in the pstools parameters as the users differ and you are trying to get the screenshot of a non-interactive session thats why its blank

    ReplyDelete
  6. @Tuwi D , or anyone....
    I have the black screen screen capture issue. How do you use the impressionate feature of pstools? I tried using the flag -i but I still have the black screen issue.

    Thanks in advance.

    ReplyDelete
    Replies
    1. Got it working.... I had to user this:

      psexec.exe -s -i \\192.168.0.120 nircmd.exe savescreenshot "C:\shot.png"

      Delete
    2. Btw, thanks OP of this article!!!!

      Delete
  7. psexec.exe \\192.168.1.10 -u "domain\administrator" -p "password" -i -c nircmd.exe savescreenshot "c:\shot.png"
    shot.png will be saved on target computer

    If you are logged on as administrator then you can skip -u and -p options, you can skip only -p then you will be prompt for a password.
    psexec.exe \\192.168.1.10 -u "domain\administrator" -i -c nircmd.exe savescreenshot "c:\tmp\shot.png"


    Save 20 screenshots every minute in a loop:
    psexec.exe \\192.168.1.10 -u "domain\administrator" -p "password" -i -c nircmd.exe loop 20 60000 savescreenshot "scr~$currdate.MM_dd_yyyy$-~$currtime.HH_mm_ss$.png"

    Gain access to remote pc via console (telnet equivalent):
    psexec.exe \\192.168.1.10 -u "domain\administrator" -p "password" cmd

    ===============================================================================================================================================================================

    Got it working.... I had to user this:

    psexec.exe -s -i \\192.168.0.120 nircmd.exe savescreenshot "C:\shot.png"

    ReplyDelete