Windows screen shots via command-line SSH session

5,519

Solution 1

Have you tried using SysInternals' PsExec utility instead of SSH? Or even in addition to SSH (ie, ssh user@host "psexec screencap --output /tmp/console.jpg"). I don't know that it would work, but seems worth trying.

Solution 2

The following method to capture remote Windows desktop via ssh login worked for me.

Tools needed:

Transfer psexec.exe/paexec.exe, miniCap to the Windows machine.

  1. Login to windows machine: PUTTY.EXE [email protected]
  2. Execute on the remote machine:
paexec.exe \\10.0.0.38 -i -d -s <path_to_program>\MiniCap.exe -nofocus -capturedesktop -save "screen_$appname$_$date$_$uniquenum$.jpg" -closeapp -exit

Solution 3

If you already have VNC on the machine you may try to make screenshots through VNC, e.g. with VNC Snapshot.

Share:
5,519
Geoff Fritz
Author by

Geoff Fritz

Updated on September 17, 2022

Comments

  • Geoff Fritz
    Geoff Fritz over 1 year

    I've browsed the handful of "screen capture" queries here, but I was unable to find anything which addressed my specific need.

    I'm looking for a command-line tool that I can run via remote SSH connection (by way of the cygwin sshd daemon). There are several to choose from, but the few I've tried (ImageMagick, nircmd, and MiniCap) all result in a blank screen. I assume that this is due to the remotely logged in user not having a proper graphical console session running.

    The goal here is automate screen capture and retrieval of the main system console (what one would see if they were looking at the physical monitor) through the use of ssh script from a Unix host:

    ssh user@windowshost "screencap --output /tmp/console.jpg"
    scp user@windowshost:/tmp/console.jpg /some/destdir
    

    Note that these must be done on demand, so polling a remote directory that has snapshots dumped periodically will not work.

    Bonus points for programs that are open source and have a portable install (so I don't need to RDP/VNC into the machine to run a graphical installer).

  • Geoff Fritz
    Geoff Fritz over 14 years
    That resulted in the same blank screen capture. Nice idea, though.
  • Geoff Fritz
    Geoff Fritz over 14 years
    Looks like the last release was in 2004. It may take some effort to get working. I'll report back in if I manage to do so.
  • whitequark
    whitequark over 14 years
    VNC protocol is very, very simple and even more, each specification refers to previous as extension. Also current version is 3.8, and 3.7 was released in 2003 IIRC, so it probably would work.
  • Vi.
    Vi. almost 14 years
    It's about Windows. There's no "display :0.0". There are desktops and windowstations instead.
  • Vi.
    Vi. almost 14 years
    You should CreateRemoteThread in some process running on the desktop you want to screenshot. May be psexec can do this, may be not (in this case you need some other tool).
  • akavel
    akavel over 9 years
    You should try adding option -i 1 to PsExec. There's some chance it might help. (For pre-Vista (?) versions of Windows, this should be -i 0 I believe.) Also, you most probably want to add -accepteula option just in case. As a last resort, if PsExec behaves not reliable enough for you and you permit yourself to do some WinAPI programming, have a look at: asprosys.blogspot.com/2009/03/…
  • reinierpost
    reinierpost almost 9 years
    This does work on Windows, with Cygwin, but only for capturing Cygwin (X) windows.