I am using a virtual private server (VPS) running Windows Server 2012 R2 Base on Amazon web services (AWS)
I am using Python imaging library and win32api to simulate mouse clicks and take screenshots.
I would like to be able to do this even when the remote desktop is not connected.
As soon as I disconnect there is no monitor available and my python program stops because it cannot click anywhere (there is no screen to click on)
Is there a way to setup a "fake" monitor or display for my VPS so it can continue to click away happily?
This is possible through the tscon command - where you can disconnect from the RDP session but the terminal is still available. I am not sure whether this will work for your python program.
The command is tscon, an example of the use is:
C:\Windows\System32\tscon.exe rdp-tcp#1 /dest:console
This depends on knowing the RDP session identifier (rdp-tcp#1 in this case). If you use the qwinsta command in a command shell. As seen below this shows the currently active session name for use in the tscon command. One issue is that each time you RDP in the session increments so you have to use the new session name each time.
C:\Users\Administrator>qwinsta
SESSIONNAME USERNAME ID STATE TYPE DEVICE
services 0 Disc
>rdp-tcp#1 Administrator 2 Active
console 3 Conn
rdp-tcp 65536 Listen
Related
Is there Python programming to connect to the ssid of a router without using CMD?
I have programming working that runs cmd batch files or sends "netsh" commands to the cmd window.
CMD is an excellent debugging tool but I can't believe it was intended to be used seriously for using with own software programming as the cmd editor needs to open, be opened or flash every time a command is sent.
It might help to mention that the stick PC I'm using does not have a physical monitor attached but with a hardware adaption to the HDMI output and VNC software installed so the screen can be viewed on any other computer with a VNC viewer. Mouse and keyboard can also control the PC stick with VNC server running.
As the VNC server will not be active until the Windows 10 has installed itself; precautions such as disabling Automatic Repair at start up, Windows Updates paused or anything else in start up that would require what, will be unseen, requests for mouse clicks or keyboard presses.
It needs programming to connect to a portable router, passively poll the connection to see if the router is still connected and reconnect whenever possible. Without Using CMD.
I have had all this working for a while. It's proving reliable to connect and run but not comfortable to watch because the batch file which loops every 10 minutes uses
netsh wlan connect ssid=YOURSSID name=PROFILENAME interface="WIRELESS NETWORK CONNECTION"
and
'name="name_of_wifi" interface="type_of_network_interface" priority=1'
It keeps opening CMD window and the reconnection first closes the VNC server so on the VNC client the VNC viewer has to be started again.
I haven't used Python yet but before I do I want to know if there is programming and/or libraries available to connect to the ssid of a wifi router without CMD.
Any help on this will be appreciated.
I want to automate a very old software (drafix) that can only be run in Windows XP, on a remote desktop.
Would it be possible to write a pywinauto script that would directly interact with the software controls, without the need to send mouse/keyboard clicks on the GUI, and then minimize the Remote Desktop screen or even lock the PC?
I need to open the program, loop through a list of file names, open each one of them and save as a different format.
I did it with some basic GUI automation - clicking on buttons if necessary, sending keyboard shortcuts and entering the file names form a list. But it isn't very reliable, and I would like to minimize the Remote Desktop window and use my PC instead of having it in the foreground.
From what I have read here, it should be possible with some workarounds, and I would need to install an older version of Python (any idea which one?) on the remote desktop to write and run the script there.
What you can do is just copying your script to remote machine and run it there. Regarding minimized or closed RDP there are few workarounds and tricks described in the Remote Execution Guide which summarizes few StackOverflow answers.
There is other way that you can control gui application on remote Desktop with pywinauto. You can use rpyc or Remote Python Call. that is a python library for rpc(remote procedure call)
https://rpyc.readthedocs.io/en/latest/
your remote computer is as server and your host is as client in rpyc.
first you you need to run rpyc_classic.py in remote computer after connect to it and use pywinauto library. for example i use rpyc for start microsip on remote computer with pywinauto.
ip of remote computer is 192.168.222.222.
import rpyc
ip = "192.168.222.222"
conn = rpyc.classic.connect(ip)
conn.execute("from pywinauto import Application")
conn.execute(r"Application().start(r'C:\Program Files (x86)\MicroSIP\microsip.exe')")
I have a sikuli script which does the Siebel Tools incremental Compilation Task on a Windows Box from Jenkins.
The problem is: When i run the task i always have to open the RDC window open for the task to be executed.As soon i minimize the window the script fails.
Hence if the Sikuli script is running i will not able to use my local system for any other task.
I found some posts on launchpad.net.
this is one reference: https://answers.launchpad.net/sikuli/+question/213636
But it did not work.
Can anyone help on this.
This solution has helped me out:
Close all open Remote Desktop sessions.
Launch the Registry editor (regedit.exe).
Navigate to one of the following Registry keys, depending on whether you wish to modify the Remote Desktop settings only for the current user or for all users on the computer:
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client
Create a DWORD value named RemoteDesktop_SuppressWhenMinimized and set it to 2.
Close the Registry Editor.
After these steps are done RDC when minimized will not be suppressed and sikuli will work.
Answer taken from:
https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/in-minimized-window.html
Other solution is to use VNC connection instead of RDC. RealVNC for example.
You setup VNC server on machine that sikuli scripts are running on and connect from your other machine. You should even be able to close the connection window and scripts should still be able to run.
You could just keep the RDC session running in the background. Just don't minimize it. I am doing the same with my tests.
I tried to do this with WMI, but interactive processes cannot be started with it (as stated in Microsoft documentation). I see processes in task manager, but windows do not show.
I tried with Paramiko, same thing. Process visible in task manager, but no window appears (notepad for example).
I tried with PsExec, but the only case a window appears on the remote machine, is when you specify -i and it does not show normally, only through a message box saying something like "a message arrived do you want to see it".
Do you know a way to start a program remotely, and have its interface behave like it would if you manually started it?
Thanks.
Normally the (SSH) servers run as a Windows service.
Window services run in a separate Windows session (google for "Session 0 isolation"). They cannot access interactive (user) Windows sessions.
Also note that there can be multiple user sessions (multiple logged in users) in Windows. How would the SSH server know, what user session to display the GUI on (even if it could)?
The message you are getting is thanks to the "Interactive Services Detection" service that detects that a service is trying to show a GUI on an invisible Session 0 and allows you to replicate the GUI on the user session.
You can run the SSH server in an interactive Windows session, instead as a service. It has its limitations though.
In general, all this (running GUI application on Windows remotely through SSH) does not look like a good idea to me.
Also this question is more about a specific SSH server, rather that about an SSH client you are using. So you you include details about your SSH server, you can get better answers.
ok i found a way. With subprocess schtasks( the windows task scheduler). For whatever reason, when i launch a remote process with it , it starts as if i had clicked myself on the exe. For it to start with no delay, creating the task to an old date like 2012 with schtasks /Create /F and running the then named task with schtasks /Run will do the trick
I've got Mac OSX running and want to programmatically manipulate a active RDP session to for instance, perform actions within a launched program within the session (dynamics specifically, yet woudn't hurt to know a universal way).
I don't know if this is possible. Currently using a RDP file to launch the RDP session with credentials and have the process ID of my active session, retrieved via NSWorkspace. With that I can do the basic stuff like closing my session again, yet i want to manipulate the session.
My RDP client currently is Microsoft Remote Desktop.
Would wish to reach my goal in either bash or python.
Here are few ideas:
Use Quartz graphics library in Python to manipulate with RDP client window. Here is a good start: How to list all windows from all workspaces in Python on Mac?
Use libfreerdp via ctypes.
Run RDP session under Wine and use tools such as AutoHotKey, AutoIT or xdottool. See: How to programmatically control X11 forwarded apps?
Use WinRM (pywinrm) instead of RDP to run remote commands/scripts. Check this example. This can allow to run auto tools mentioned above (e.g. AHK script controlling the apps).
Use Python GUI automation library for simulating user interaction in apps.
See also: GUI scipting for Linux.
Write an RDP client that dumps the pixels of the screen. E.g. WebRTC or using libFreeRDP.
If RDP client runs via X11 protocol (Quartz), you can try to tap into X11 requests as per this post.
Use FreeRDP and its API. Its client is compatible with Linux, macOS and Windows.