Jump to content

AutoIt stops working after disconnecting from RDP


Recommended Posts

Hi,

I know there are dozens of threads like this but I've read literally every single one (I think so, at least).

So my problem is that the "bot" which I have created stops working when I disconnect from the VPS. (Bot is nothing special, just a program that goes to 2 pages and presses there on a few specific places in a loop.)

Following things are listed which I have tried already:

  • VNC Viewer (bad image quality and yes, I am dependent on the GUI. Because of the use of WinWait or AutoClick the coordinates for the mouse change).
  • RDP over RDP which worked back then but doesn't now for some reasons. For the ones who don't know the steps (just with the difference that I use 127.0.0.2 instead of 127.0.0.1 since it's in use already by a different program (VPN):
Spoiler
  1. From your own desktop, login to your server via RDP using original 'user1' credentials.
  2. In the remote server logging in as 'user1' - install and run your bot.
  3. In the remote server logging in as 'user1' - create a new user - 'user2'.
  4. Disconnect your RDP session logging in as 'user1'.
  5. From your own desktop, re-connect your RDP session to your remote server - but this time login using 'user2'.  
  6. Once you are in your remote server logging in as 'user2', you should see an 'empty' desktop without any bot running.
  7. 7. In the remote server logging in as 'user2', create a new RDP profile with Computer - 127.0.0.1 and User name: user
  8. In the remote server logging in as 'user2', you should see your bot running in the RDP session[user1] within your RDP session[user2].
  9. From now on, on your own desktop, just use the RDP profile you have created in step 5 to check your bot.
  • I compiled the script to a .exe and then created a service as somebody suggest here

I really hope that someone can help me because I'm really desperate right now. Thanks!

Link to post
Share on other sites
6 hours ago, Bert said:

Here is the thing - you are using the word "bot" which is a red flag for us. Normally that sort of thing is used for games which is a banned topic here in the forum. Would you care to share what application on the remote desktop you are interacting with?

I'm sorry but he could answer anything. I won't push this topic forward. When I see "bot" and "mouseclick" at the same place I just don't answer. 

And bot have nothing related to game but to ro"bot" which yeah are used often for game automation.

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to post
Share on other sites

I am going to answer this question because the primary objective is not related to game automation at all, there are many legitimate applications which can be automated in a Windows server.

14 hours ago, Two1 said:

RDP over RDP which worked back then but doesn't now for some reasons.

This was my go-to approach, sad to know that it no longer doesn't work, perhaps you can try an older version of the server if that is a possibility?

The problem happens because there is no display attached to the machine after the RDP client disconnects, RoR solved this issue by simulation a display connection from the same machine itself.

I looked for other virtual display solutions, perhaps a driver which could simulate a virtual screen, but I couldn't find any. Here is a stackoverflow thread I started for reference: https://stackoverflow.com/questions/43841450/uiautomation-wont-work-in-windows-server-vps-if-i-am-not-connected-via-rdp

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
11 hours ago, Bert said:

Here is the thing - you are using the word "bot" which is a red flag for us. Normally that sort of thing is used for games which is a banned topic here in the forum. Would you care to share what application on the remote desktop you are interacting with?

Thank you for your answer and I am sorry if there were any misunderstandings. I don't want to post my code here publicly, but can send it to you privately (if you wish).

As written the "bot" (that's why I wrote it in quotation marks) is a program that goes to the specified site (by me) and gather the information there for me which will in return sent to my phone. It is like a news ticker for the cell phone with mobile push notifications and I don't know what that has to do with games. If I were you, I wouldn't drill here, but rather at one of the real big game automations that have created a Clash of Clans Bot with this scripting language (which is public knowledge).

Link to post
Share on other sites
4 hours ago, caramen said:

I'm sorry but he could answer anything. I won't push this topic forward. When I see "bot" and "mouseclick" at the same place I just don't answer. 

And bot have nothing related to game but to ro"bot" which yeah are used often for game automation.


I AM sorry, but in what way should your answer to my help contribute now? As your speaker above mentioned, this is NOT a bot to automate games (admittedly I don't have the best AutoIt knowledge, so I use simple commands like "mouseclick" because I have problems with more complex commands like "controlclick").
By the way, according to the Internet, a bot is defined as follows: "A bot is a computer program that executes repetitive tasks largely automatically without the need for interaction with a human user".
And EXACTLY that is what I want. I want to automate tasks for me!

 

Link to post
Share on other sites
3 hours ago, TheDcoder said:

I am going to answer this question because the primary objective is not related to game automation at all, there are many legitimate applications which can be automated in a Windows server.

This was my go-to approach, sad to know that it no longer doesn't work, perhaps you can try an older version of the server if that is a possibility?

The problem happens because there is no display attached to the machine after the RDP client disconnects, RoR solved this issue by simulation a display connection from the same machine itself.

I looked for other virtual display solutions, perhaps a driver which could simulate a virtual screen, but I couldn't find any. Here is a stackoverflow thread I started for reference: https://stackoverflow.com/questions/43841450/uiautomation-wont-work-in-windows-server-vps-if-i-am-not-connected-via-rdp

 

11 minutes ago, BigDaddyO said:

I've never done the RoR before.

I used to connect from Laptop to Server2, then from Server2 to Server1, then disconnecting my Laptop connection to Server2 would leave Server1 with an active desktop.

 

You could also try this

 

Thank you both for your answers. I will check it out and get back to you if I get any problems or something.

Link to post
Share on other sites

You have to understand mate, here, when you're talking about bot and mouse click. You will be flagged as game automater here. Which is killing our community.

Btw you're just repeating what I said. ;)

 

You got your computer A

You remote access to 1 with A

From 1 you connect to 2 

Then from here, you could disconnect A. 

 

The purpose of 1 is to keep the screen of 2 active. Without a screen, you couldn't mouse click. 

The bad point in this is : You will run two computers to keep one active. It is the same as doing it from your own computer and let the MSTSC active.

 

 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to post
Share on other sites
2 hours ago, caramen said:

You have to understand mate, here, when you're talking about bot and mouse click. You will be flagged as game automater here. Which is killing our community.

Btw you're just repeating what I said. ;)

 

You got your computer A

You remote access to 1 with A

From 1 you connect to 2 

Then from here, you could disconnect A. 

 

The purpose of 1 is to keep the screen of 2 active. Without a screen, you couldn't mouse click. 

The bad point in this is : You will run two computers to keep one active. It is the same as doing it from your own computer and let the MSTSC active.

 

 

That's exactly what I have tried!
I even tried that with 2 different RDPs.

From my own PC I connected to the second user of the RDP. There I opened RDP and connected to the first user via 127.0.0.2. After leaving the 127.0.0.2 window on and disconnecting from the second user from my own PC the program stops working.

And here are the steps with the second RDP:

- connecting to the first RDP

- from there connecting to the second RDP and leaving that window open

- disconnecting from the first RDP

Both steps don't work and I don't know why.

Link to post
Share on other sites
25 minutes ago, Two1 said:

The purpose of 1 is to keep the screen of 2 active. Without a screen, you couldn't mouse click. 

That should anticipate the fact. :) 

If you still have issue using this workaround, you have to check what is happening when you're disconnecting. 

A)-It could be screen saver (this parameter have to be checked on 1 & 2).

B)-Or if you disconnect from 1 the session have multiple behavior

__The session remain active (you have to set this one)

__The session is totally closed. (this one will obviously disconnect your session from 1 to 2)

To make things easy, consider the script/bot/tool only need the screen of TARGET(S). 

So, be aware you need the screen of 1 & 2 if you start the script from 1 (and useless workaround if you do so) and you only need the screen of 2 if you start the script from 2. 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to post
Share on other sites
  • Moderators

Two1,

When you reply in future, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - responders know what they wrote and it just pads the thread unnecessarily. Thanks in advance for your cooperation.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

I'm sorry for the mess @Melba23.

@caramenUnfortunately your suggested solution (along with the other solutions) did not work. I still can't figure that out :(
Do you still have any tips that could help me? I even tried that with 2 RDP but I still get the same outcome just like with one RDP (and there 2 accounts and connecting to 127.0.0.2).

Link to post
Share on other sites

Yo, You can try to enable RDP keep alive functionnality in the registry:

In regedit.exe as admin:

-Go to the location HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server
-Create or edit the DWORD value of KeepAliveEnable
-Set it to 1.
-Save and quit

Quote

By default, Remote Desktop Services allows users to disconnect from a remote session without logging off and ending the session. When a session is in a disconnected state, running programs are kept active even though the user is no longer actively connected.

https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc754272(v=ws.11)?redirectedfrom=MSDN

By default, 

Quote

"running programs are kept active even though the user is no longer actively connected."

So if you don't keep your program active it is because a setting has been changed on your workstation. You have to figure out which one it is. 
Most of the time you will encounter that kind of settings when a lot of user attempts to connect on the workstation. Remove it can result in a workstation where peoples won't be able to connect. There is a limit of active session depending on the actual Windows license used.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to post
Share on other sites

Thanks for your commitment @caramen I appreciate that but I tried that earlier.

What seems to work in my case is the batch file with the code

for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (tscon.exe %%s /dest:console)

I created a batch file and then created a desktop shortcut with that batch file since I changed the rights to run the program under the tab "advanced" (so I can run with admin rights).

It kicked me out of the RDP (as it should) and now it's displaying the GUI on the disconnected RDP for the bot/program which is needed.

Thanks again everyone who tried to help me!

Thread can be closed @Melba23

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...