0

I'm writing a script to perform some actions (e.g: execute scripts, copy/paste/rename etc) on a remote machine. The remote machine only has RDP, VNC and FTP activated. I can perform all the above mentioned actions manually using a RDP/VNC viewer but I want to automate them. Initially I wrote my script in Python but I can change to Powershell if necessary. SSH would solve all the problems but unfortunately its not available on the remote machine.

I tried to connect through psexec but its been disabled.

Is it possible to control the remote machine through Python/Powershell using RDP/VNC?

Farahi
  • 1
  • related question: https://superuser.com/questions/490932/command-line-rdp-call-cmd-on-target-machine – Robert Nov 24 '21 at 13:34

1 Answers1

0

Neither RDP or VNC supports this.

The best you can do is to RDP/VNC to the remote machine.
Copy your script over (if file-transer is disabled you can always open Notepad on the remote and copy/paste the script content from your local PC to Notepad on the remote and save it there).
Then run your script remotely.

Tonny
  • 29,601
  • 7
  • 52
  • 84
  • I can transfer the scripts through FTP which is enabled. But I want to run the scripts and get results automatically. – Farahi Nov 24 '21 at 13:35
  • @Farahi Run them as Scheduled Tasks on the remote system and have them dump the output files in a folder that is shared by the ftp. Retrieve them from the ftp server. – Tonny Nov 24 '21 at 14:55
  • Dumping the output in files is a good idea but unfortunately running scripts as scheduled tasks is not sufficient. I need to be able to trigger them manually. – Farahi Nov 24 '21 at 15:05
  • @Farahi Then get SSH enabled. If they are unwilling, you can try selling it to them as a security improvement. You don't need the hopelessly unsecure FTP (seriously... FTP sends userids/passwords as plain text over the LAN...) if you have SSH, because you can run the file-transfer over SSH. (And you can tunnel RDP and/or VNC over SSH as well. Even bigger improvement. Only 1 port to expose.) – Tonny Nov 24 '21 at 16:38
  • SSH would be amazing but the problem is that there are hundreds of these machines in the wild. For SSH to be enabled, a technician will have to go to every machine and set up everything manually. I don't think there's anyway I could sell this idea to the management. – Farahi Nov 25 '21 at 09:20
  • @Farahi Now you tell me there are hunderds of these... Well... you can sort of fake manual triggering. Simply setup a scheduled task that runs every X minutes. The task looks in one of the FTP folders for a "trigger.bat" file and simply executes the content if it exists. After it is done it deletes the trigger.bat file. Whenever you need to initiate something manually you just upload the trigger.bat to the remote machine. You need to do a one-time setup on the each remote machine, but that doesn't require admin-rights or any changes to the exisiting setup. – Tonny Nov 25 '21 at 11:33
  • If it was possible to do a one-time setup on each machine then they would just setup SSH. I think I have to give up this idea and come up with some other way. Thank you for your time. – Farahi Nov 25 '21 at 12:02