okdewit Posted April 28, 2008 Posted April 28, 2008 (edited) Hey all! On one of the servers I manage for a company there is a tool which runs as an executable. This tool has a GUI (monitor) and sends secured reports to other companies (mainly banking and financial companies). Problem with this tool is that the manufacturer didn't program it very well, so it crashes once in a while because of memory errors. My solution: I have an autoit executable which checks if the GUI is still open if the process is running and if there aren't any warning windows. Problem is that the server locks itself after 10 minutes (it says something like "this computer is locked and can only be unlocked by "user" or domain\administrator"), And then it stops detecting the warning windows (for which I use "If winexists("warning window") then processkill("tool"), run("tool") etc.) Is there any way I could keep the server secure and still let the script do its work? The warning window also displays when the server is locked, but it doesn't get detected by my script. Many thanks in advance!! EDIT: Here the main code, in case that helps (log entries which are created in dutch): If Not ProcessExists("fdn_server.exe") Then Run("K:\Maex\fdn_server.exe","K:\Maex") $File = FileOpen("FDNStarter.log",1) FileWriteLine($File,"FDN Herstart om: "&@HOUR&":"&@MIN&" Datum: "&@MDAY&"-"&@MON&"-"&@YEAR&" ||| REDEN: Proces is afgesloten, handmatig gestopt of afgesloten door onbekende reden") FileClose($File) Sleep(5000) ElseIf WinExists("MMP/FDN-verkeer: fdn_server.exe - Application Error") Then WinKill("MMP/FDN-verkeer: fdn_server.exe - Application Error") ProcessClose("fdn_server.exe") Run("K:\Maex\fdn_server.exe","K:\Maex") $File = FileOpen("FDNStarter.log",1) FileWriteLine($File,"FDN Herstart om: "&@HOUR&":"&@MIN&" Datum: "&@MDAY&"-"&@MON&"-"&@YEAR&" ||| REDEN: Crash door memory error in FDN server") FileClose($File) Sleep(5000) Else _ReduceMemory() Sleep(5000) EndIf Edited April 28, 2008 by okdewit
herewasplato Posted April 28, 2008 Posted April 28, 2008 WinWait, WinExists, WinKill and WinSetTitle will work when XP is locked and I would think that it would be the same for other operating systems. Try this code - start script and lock the computer during the 10 second sleep...Opt("WinTitleMatchMode", 2) Sleep(10000) Run("cmd") WinWait("cmd.exe") If WinExists("cmd.exe") Then WinSetTitle("cmd.exe", "", _ "WinWait, WinExists and WinSetTitle will work when locked") EndIf SoundPlay(@WindowsDir & "\media\chimes.wav", 1)...I did test for WinKill, but I wanted to leave the window up for you to see after you unlock the computer. I would have the script lock the computer, but doing a Send("#l") made the # key stick down :-( [size="1"][font="Arial"].[u].[/u][/font][/size]
herewasplato Posted April 28, 2008 Posted April 28, 2008 ...The warning window also displays when the server is locked, but it doesn't get detected by my script...When you unlock the server and see the error window, does you script continue at that point - does your script kill the window and write to the log file?In other words, have you seen your script work as expected on this error window while the server is unlocked?If all else fails, you can run you script and the application inside a Virtual PC (or Virtual Machine) and all AutoIt functions will be available. The VM can remain unlocked but the host computer can be locked. http://www.microsoft.com/downloads/details...A2-2DC0B40A73B6 is free - except you will need an OS license. [size="1"][font="Arial"].[u].[/u][/font][/size]
Xenobiologist Posted April 28, 2008 Posted April 28, 2008 Hi, I did a quick test with this: #include <GUIConstantsEx.au3> ; Test Fenster erkennen bei gesperrtem Windows. Send('#l') __createGUI() Sleep(2000) While 1 _detect() Sleep(250) WEnd Func __createGUI() Local $msg GUICreate("My GUI") GUISetState(@SW_SHOW) EndFunc ;==>__createGUI Func _detect() If WinExists('My GUI') = 1 Then MsgBox(64, 'FOUND', 'FOUND') Exit (0) EndIf EndFunc ;==>_detect Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
herewasplato Posted April 28, 2008 Posted April 28, 2008 (edited) Mega - how could you tell if your code worked while locked or worked as soon as you unlocked? Edit: ...and did your # key stick. As soon as I unlocked my computer, I went to type a comment in the code " ; locks computer " but as soon as I hit the "l", the computer locked again. I've been seeing this a lot... have you? Edited April 28, 2008 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Xenobiologist Posted April 28, 2008 Posted April 28, 2008 Mega - how could you tell if your code worked while locked or worked as soon as you unlocked?Cause the MsgBox plays a sound. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
herewasplato Posted April 28, 2008 Posted April 28, 2008 Cause the MsgBox plays a sound.Ah - that is what I get for having "no sound" selected on all of my systems. [size="1"][font="Arial"].[u].[/u][/font][/size]
Xenobiologist Posted April 28, 2008 Posted April 28, 2008 Ah - that is what I get for having "no sound" selected on all of my systems. you can combine it with this piece of code While 1 Sleep(1000) If _isWorksatationLocked() Then ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & " - " & "workstation locked" & @CRLF) WEnd Func _isWorksatationLocked() If StringInStr(WinGetText(""), "Program Manager") <> 0 And WinGetTitle("") = "" Then Return 1 Return 0 EndFunc ;==>_isWorksatationLocked Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
herewasplato Posted April 28, 2008 Posted April 28, 2008 (edited) Yep - I forgot about that UDFBTW - my code above is from another post.I probably would not have picked the cmd window to demo if I had not copied the code from here http://www.autoitscript.com/forum/index.ph...st&p=369347Well, now we await feedback from the OP. Edited April 28, 2008 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
okdewit Posted April 29, 2008 Author Posted April 29, 2008 Thanks a lot for all the answers. I used pieces of your code, confirmed that everything worked. The script did NOT continue to work after the server was unlocked, and after viewing the eventlogs I noticed that the server was just screwed up in many more ways. I could'nt kill the process manually either, so it wasn't the script, it was the server itself. After a reboot and fixing the problem that made the server freeze my script is working perfectly now. Thanks!
Xenobiologist Posted April 29, 2008 Posted April 29, 2008 Speaking for both of us! Glad we could help! Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now