0

I am running a windows VM on Amazon EC2 which is a 2016 server.

I have a script set up that uses a graphical image search function to find some data. This runs perfectly fine when I am remotely connected, and I have scheduled it to run at 2am, so that I can automatically boot the instance up, have the script run, and then power the instance down without me needing to do anything.

However, the script fails when I am not connected via RDP, because it can't find the images because the GUI isn't being rendered.

What I am looking for is a way to have the GUI be rendered when I'm not connected via RDP, and I haven't been able to find any solutions to this problem online.

To further illustrate the problem, If I log on, and run the script manually via RDP, it starts to work. However, if I close the RDP connection, the script still runs, but doesn't succeed as it can no longer get image data. I want my script to be able to get image data while there is no active RDP connection.

Edit: this is different from the linked topic as I am trying to use the graphical features of the OS, rather than just running a script automatically.

  • 1
    Possible duplicate of [Windows: Running an AutoIt script to launch a GUI app - on a server, when no one is logged in](https://serverfault.com/questions/47431/windows-running-an-autoit-script-to-launch-a-gui-app-on-a-server-when-no-one) (I think...) – Lenniey Jan 04 '18 at 13:40
  • I read that and don't think so, as I am able to launch the GUI app remotely (and also run commands on the server via the scheduled task manager), but what my script requires is imagesearching and screenshots, which fail when there isn't an RDP connection (as no graphics are displayed at all) – user450659 Jan 04 '18 at 13:43

1 Answers1

0

I would try the following approach:

  1. Configure auto logon

    a. Let the system automaticly login after starting as a specific user with Autologon: https://docs.microsoft.com/nl-nl/sysinternals/downloads/autologon

    b. OR set a registry key to perform this task: https://technet.microsoft.com/en-us/library/cc939702.aspx

  2. Configure a scheduled task to run after logon (NOT after startup) which starts the desired script.

This way the script runs in the console session. Monitoring it would be harder (does EC2 has option to view and work in console session?). However you can always install some kind or remote administration tool to view the console session.

eKKiM
  • 1,540
  • 9
  • 23
  • Hi, thanks for the response. I have these scheduled, but the issue is that my script fails because it can't get any image data as there is no GUI. I'm wondering if there is a way for windows server 2016 to render the GUI without having an RDP session connected to it. – user450659 Jan 04 '18 at 15:48
  • afaik every windows installation has a console session. (console session is the session you see when you connect monitor to the server). You just need to make sure your script is run in this session (There always is a GUI available in this session..) Teamviewer Host has an option to connect directly to the console session: https://community.teamviewer.com/t5/TeamViewer-11/How-to-access-Teamviewer-on-a-windows-server-console/td-p/1069 – eKKiM Jan 04 '18 at 15:59
  • I've got teamviewer running and you're right, when my script runs in a console session it works - thanks a lot. My question now is how to automate this. Can I run a console session with a powershell command? Having to teamviewer in puts me in a similar boat to RDP'ing.. – user450659 Jan 04 '18 at 18:27
  • This console session is always active. Even if you disconnect from TeamViewer. The only thing you need to make sure is that you use auto login. This way after starting the machine the console session is active with the given username. – eKKiM Jan 05 '18 at 13:39