rdesktop icon indicating copy to clipboard operation
rdesktop copied to clipboard

Shell command not working

Open jamessemai opened this issue 8 years ago • 11 comments

I am unable to get the -s (shell) parameter working.

E.g. the following does NOT work:

rdesktop -u <user>-p <password>-s "calc.exe" <IP>

It does connect an RDP session, but never launches calc.exe. Testing against Windows 7 and Windows Server 2008 R2.

Can someone confirm this is supposed to work "out of the box" on a Windows 7/Windows Server 2008 R2 machine? Since I do not find issues with this on the internet, I suspect there must be something specific to my test machines.

Are there any conditions required for this to work? How can I further debug this?

jamessemai avatar Dec 18 '17 14:12 jamessemai

For completeness, I tried both 1.8.3, and master - my client machine is running CentOS 7.4

jamessemai avatar Dec 18 '17 14:12 jamessemai

I'm a bit unsure but i think the shell functionality changed for win7 and on forward to be part of "Remote App". I tried to set shell to notepad using mstsc.exe and a rdp file and connect to Windows 7 and got a full desktop. I also tried the same RDP file but against an Windows 2016 RDS collection where I got an "Access denied" message when the application is not enabled through "Remote App".

The same behavior as when performing the same tests using rdesktop with one exception, rdesktop does not support "Remote App" and will fail if application is enabled server side.

hean01-cendio avatar Dec 18 '17 14:12 hean01-cendio

Ah, if the shell functionality relies on RemoteApp, that would explain it, as RemoteApp requires some additional configuration to work (e.g. fAllowUnlistedRemotePrograms to 1, or fDisabledAllowList to 1).

Let me check that.

jamessemai avatar Dec 18 '17 14:12 jamessemai

Doesnt seem to be it.

If I add HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\fAllowUnlistedRemotePrograms and set that to 1, RemoteApp starts working, as proven by freerdp:

xfreerdp /u:[user]/p:[pw] /app:calc.exe /v:[IP]

This launches calculator in a dedicated window.

However, the rdesktop command still just shows the desktop, without launching calc.exe:

rdesktop -u <user> -p <password> -s "calc.exe" <IP>

jamessemai avatar Dec 18 '17 15:12 jamessemai

The difference is that xfreerdp does support RemoteApp while rdesktop does not.

hean01-cendio avatar Dec 18 '17 15:12 hean01-cendio

Ah, I misread your earlier comment.

I thought you meant that rdesktop relied on RemoteApp for its shell functionality. However, you meant that you suspect that Microsoft has stopped supporting the original rdesktop shell functionality starting Win7, in lieu of its RemoteApp functionality.

That would explain my test results. Would be nice to get this confirmed though.

jamessemai avatar Dec 19 '17 11:12 jamessemai

Are you aware of any other mechanism in rdesktop that allows the execution of a command/script on a Win7 machine (without user interaction)?

jamessemai avatar Dec 19 '17 11:12 jamessemai

I'm sorry for the confusion. I have found that 'alternate shell' should work as expected with Windows 7. The problem you have might just be that you need to provide a full path to the executable to be run as alternate shell.

hean01 avatar Dec 19 '17 21:12 hean01

Can you share the command that is working for you?

I tried:

rdesktop -u <user> -p <pw> -s 'C:\Windows\system32\calc.exe' <IP>
rdesktop -u <user> -p <pw> -s 'C:\\Windows\\system32\\calc.exe' <IP>
rdesktop -u <user> -p <pw> -s 'C:/Windows/system32/calc.exe' <IP>

None of those works for me.

jamessemai avatar Dec 20 '17 11:12 jamessemai

Same here with rdesktop 1.8.3: the program specified in the "-s" argument is not executed at session start: only the desktop is shown. Any way to grab logs of the connection?

bperel avatar Feb 12 '18 09:02 bperel

Hello, I am having the similar issue with "-s". I am connecting to an Ubuntu machine and want to execute some script once I do log in via rdesktop. I am trying to do rdesktop -u <user> -p <pass> -s "date" <IP of Ubuntu Machine> rdesktop -u <user> -p <pass> -s "/usr/bin/gnome-terminal" <IP of Ubuntu Machine>

I am able to get the screen but command is not fired.

Please let me know if you guys have another way to accomplish the same. thanks.

pranavgore09 avatar Aug 22 '18 03:08 pranavgore09