Is there a lightweight way to start an application on a remote win7 machine from linux?

Solution 1:

RSHD will do exactly what you are looking for. It can run in the context of the currently logged on user, and listens on a port for incoming connections from pre-authorised hosts. You could send a command (e.g. calc.exe) and have the app appear on the user's desktop.

Note that there are many implementations, and I wouldn't like to recommend one over another, some run as a service, but you will probably need to find one that runs in the context of the logged on user to do what you are asking.

Edit in response to the comment:

I've used this one in the past to do exactly as you are asking. It's lightweight, just a standalone binary.

Firstly, on the windows PC create a rhosts file and save it as c:\windowsrhosts (note this isn't a typo, this file exists in the root of the C: drive). The file should contain the FQDN of the remote linux computer you are going to connect from, followed by the username, e.g.

remotepc.example.com bryan

Next, create a batch file that executes on logon, with the following command

rshd.exe -d

This will leave a command prompt window, which you can minimise.

Download a RSH client on your Linux PC (I've only tested using a Windows RSH client)

I've just tested, and have launched calc using the following command

rsh windowspc.example.com -l bryan calc

...and up popped calc.exe on the Windows desktop.

Solution 2:

I know this thread is 3 years old but here is a solution I found.

For some reason, winexe's '--interactive=1' does not behave like psexec's '-i' option. With winexe, the user will still have to accept an 'Interactive service detection' dialog.

A possible solution is:

1 - using smbclient or CIFS shares to upload psexec to the windows machine. 2 - (optionally) uploading the GUI program that you want to run. 3 - running the GUI program through psexec through winexe. Like this:

winexe --uninstall --interactive=0 -U 'WinAdmin%WinAdminPasswd' //1.2.3.4 '\windows\temp\psexec.exe -i \\127.0.0.1 -u WinAdmin -p WinAdminPasswd notepad.exe

And notepad will successfully appear on the logged-on user's desktop.

In case the 'Interactive services detection' dialog still appears, the service must be disabled beforehand and then re-enabled:

winexe --interactive=0 -U 'WinAdmin%WinAdminPasswd' //1.2.3.4 'cmd /c sc config UI0detect start= disabled > NUL & sc stop UI0detect > NUL'
// (do your stuff)
winexe --interactive=0 -U 'WinAdmin%WinAdminPasswd' //1.2.3.4 'cmd /c sc config UI0detect start= manual > NUL & sc start UI0detect > NUL'