Sign in to follow this  
Followers 0
sh1n

Running Script with the Windows locked

7 posts in this topic

Hi all!

Anyone knows how i can do to run a script (which uses functions like WinWaitActive) when my windows is locked?

Or have better solution to the follow problem:

I have a machine which several users connect using WTS. This users uses a certain program.

I made a script that open that program and measures the time to open and do a certain operation.

Until here its all ok.

I need to call the script that i made from other machine (running a monitor tool, like nagios). - This part is OK

But the problem is:

If I not logged on the machine - the script dosn´t run.

If I have a open session and is active on the machine It´s all Ok.

but...If i have a open session but is locked, the script don´t run as the expected. He loops in the (WinWaitActive), off couse because the window is not active.

Thanks for your attention.

waiting for replys

and sorry for my english :)

Share this post


Link to post
Share on other sites



You could put in the ...(im going mindblank...) that place, were you put.. (Haha got it!) Scheduled Tasks, put itself in there, then just tell it what time to run, put it whenever, and then, it will wait for windows to lock...

Although, this might not work, it is a suggestion

Share this post


Link to post
Share on other sites

R6V2 thanks for your reply

But this is not my case.

The script will run, times from times.

And it is a remote machine that start the execution in the machine wich contains the script.

Anyway thanks R6V2!

Anyone have more ideas?

Share this post


Link to post
Share on other sites

To tell the truth, I don't know if programs can still run while the computer is locked, but maybe if they can be, have your script running in a small loop to check for keystrokes/mouse movements to signify that the computer is going to be locked, if you see that, put the program inside the main loop, that will do everything it needs to do.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

There is something that can allow this to happen, but I wouldn't be surprised if it's not a public method. Try hitting the Winkey+U when a workstation is locked for example.

Edited by spudw2k

Share this post


Link to post
Share on other sites

To tell the truth, I don't know if programs can still run while the computer is locked, but maybe if they can be, have your script running in a small loop to check for keystrokes/mouse movements to signify that the computer is going to be locked, if you see that, put the program inside the main loop, that will do everything it needs to do.

Of course program can run when windows is locked, test starting audio encoding or something and lock your computer.

The topic is interesting though since I too have had this problem, it seems like some function don't work properly when in locked mode. Like win functins and shutdown.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hm... I hope I can hook to that thread as my problem seems similar and a solution to mine might be the same as one to sh1n's.

I'm connecting to a server via RDP to use a certain program (for bounce handling, but that's not the point). That program runs significantly more performant when the screenlog it produces is cleared manually in regular intervals. This can be done by one mouse click and thre keystrokes. The best interval is 5 minutes and the software runs 24/7. I know it's a workaround and I know that it's obviously stupid of the program to require doing so manually, but that's the way it is.

Point is that the flushing (as I call it) works perfectly on my local machine. It also works fine as long as I keep the remote desktop connection open while being logged in. But as soon as I shut down the RD the server locks itself as it's supposed to do and the flusher can't find the window. One of our technicians told me that it's a common problem that you can't "find" a window on a locked Windows station. Now I'm in need for a workaround.

However, along comes the code (with some stuff Xed and Yed out) in case it helps finding a solution:

AutoItSetOption("WinTitleMatchMode", 2)
AutoItSetOption("RunErrorsFatal", 0)
TraySetToolTip("eMail Bounce Handler AutoFlusher")

; interval between flushes in minutes
$flushinterval = 5

; tooltip for the systray icon
$tooltip = "eMail Bounce Handler AutoFlusher"

; indicator strings to match the window
$wintitle_XXX = "XXX-TITLE"
$wintitle_YYY = "YYY-TITLE"
$tab_text = "Verbindungsprotokoll in Datei ausgeben"
; ===========================================================

While 1>0
    If WinExists($wintitle_XXX, $tab_text) OR WinExists($wintitle_YYY, $tab_text) Then
        WinSetState("", $tab_text, @SW_RESTORE)
        WinActivate("", $tab_text)
        WinWaitActive("", $tab_text, 1)
        $size = WinGetPos("", $tab_text)
        $clickX = $size[0]+100
        $clickY = $size[1]+300
        MouseClick("left" , $clickX, $clickY)
        Send("^a")
        Send("{BACKSPACE}")
        WinSetState("", $tab_text, @SW_MINIMIZE)
    EndIf
    $realdelay = $flushinterval*60*1000-1
    TraySetToolTip($tooltip & @CRLF & " (last flush check: " & @HOUR & ":" & @MIN & ":" & @SEC & "; interval: " & $flushinterval & " minutes)")
    Sleep($realdelay)
WEnd
Edited by Floutsch

Share this post


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
Sign in to follow this  
Followers 0