5

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).

1

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

2
  • 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. Jan 21 '10 at 21:48
  • 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.
    – whitequark
    Jan 21 '10 at 22:03
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.

3
  • That resulted in the same blank screen capture. Nice idea, though. Jan 21 '10 at 21:44
  • 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).
    – Vi.
    Jul 13 '10 at 19:48
  • 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/…
    – akavel
    Dec 30 '14 at 12:44
1

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 admin@10.0.0.38
  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
0

if you log into the machine via ssh you are not in the same session as the windows you want to capture. thus your snapshotting efforts are .. useless.

i would setup the windows machine to allow rdesktop-sessions, then connect via rdesktop from the unix machine and make a snapshot of the rdesktop-window.

0

You need to download and install psexe and nircmd on your remote machine and make sure they work.

Usage: Login ssh user@192.162.0.10

Then run this command (remote machine ip address):

psexec \\192.168.0.10 -d -i -s nircmd savescreenshot C:\Users\johndoe\Downloads\www\screen.jpg
-2

Try one of the following commands.

$ import -pause 1 -window root screenshot.jpg

$ xwd -out screenshot.xwd -window root
or
$ xwd -out screenshot.xwd -window root -display :0.0  

And this for extracting the xwd-file:

$ xwud -in screenshot.xwd
or
$ convert screenshot.xwd screenshot.jpg

Source: http://ubuntuforums.org/showthread.php?t=107580

2
  • It's about Windows. There's no "display :0.0". There are desktops and windowstations instead.
    – Vi.
    Jul 13 '10 at 19:46
  • This does work on Windows, with Cygwin, but only for capturing Cygwin (X) windows. Jun 9 '15 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.