Jump to content

WinExists when Run as shell


Recommended Posts

hello. I am trying to setup a script to make it easier for a few people. When someone logs into their computer I want it to auto login via RDP to a remote machine.

The problem is my script works as intended when run in windows as a program, but when its compiled and run as the user shell instead of explorer it does not detect "Your remote desktop session has ended". 

Any idea how to make the WinExists / WinClose lines work when Autoit is the shell? 

#include <Misc.au3>
#include <MsgBoxConstants.au3>

Local $hDLL = DllOpen("user32.dll")

If _IsPressed("11", $hDLL) Then
    Run("explorer.exe");

Else
    Run("mstsc.exe " & @WindowsDir & "\RDP\" & @UserName & ".rdp");
    MsgBox($MB_SYSTEMMODAL, "Title", "testing 1 2 3" );
    While(ProcessExists ( "mstsc.exe" )) 
        ;MsgBox($MB_SYSTEMMODAL, "Title", "testing 1 2 3" )
        
        if (WinExists ( "" , "Your Remote Desktop session has ended" )) Then
            WinClose (  "" , "Your Remote Desktop session has ended");
        Endif
        
        sleep(1000);
    Wend
    
    Run("shutdown.exe -l -f");
    
EndIf

 

 

I have everything mostly good except that the most common way a user is logged out of RDP is when they login to the next terminal.   Use case is there is 10 rooms and 10 users. Every few minutes the users get up and move to the next room, The last user moves to the first room. They need to be able to pickup where they last left off, but each user should not be able to access the other users content. 

These users generally do not understand much about a computer and I am trying to make this seemless for them.

 

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...