DEVIOUZ Posted October 16, 2007 Share Posted October 16, 2007 Is there a code that can check to see if a certain process is running, and if its not found running then the AutoIt.exe will execute it ..?? and also i want the AutoIt.exe to run in an infinite loop checking every 1 min if the process is running or not... How can i do this..?? Link to comment Share on other sites More sharing options...
tAKTelapis Posted October 16, 2007 Share Posted October 16, 2007 Apparently you haven't read the helpfile, go and look for: Run() ProcessExists() If ... Then While... WEnd In the helpfile. AutoIT is capable of doing exactly what you ask. Link to comment Share on other sites More sharing options...
Foy Posted October 16, 2007 Share Posted October 16, 2007 or click the knowledge is power link in tAK's siggy. Link to comment Share on other sites More sharing options...
tAKTelapis Posted October 16, 2007 Share Posted October 16, 2007 (edited) Oooh, Nice spot Foy Meanwhile, i have complete this script myself, it is 4 lines. I might aswell give it to you (But for future reference, Helpfile) While 1 ; Opens up a WHILE loop, with 1 as a constant, so it is infinite If Not ProcessExists("notepad.exe") Then Run("notepad.exe") ; if the process of notepad.exe doesn't exist, it starts it Sleep (10) ; Puts the script to sleep for 10 milliseconds so it doesn't chew CPU power WEnd ; Closes the loop, tells it to go back to the beginning Edited October 16, 2007 by tAKTelapis Link to comment Share on other sites More sharing options...
DW1 Posted October 16, 2007 Share Posted October 16, 2007 If for some reason you NEED it to run only once a minute ( or just cause I was bored ): $StartTimer = TimerInit() ; Define the initial time we will be comparing to later $process = "notepad.exe" ; define the process $exe = @SystemDir & "\notepad.exe" ; Define the executable Checkprocess() ; Run our checkprocess() function on initial execute While 1 ; Infinite Loop Condition is always true, you can exit these loops with "ExitLoop" If TimerDiff($StartTimer) > 60000 Then ; Only run the conditional code if the difference in time is greater than 1 min (60000 Miliseconds) Checkprocess() EndIf Sleep(10) ; So we don't kill the CPU WEnd ; End of While Loop Func Checkprocess() If Not ProcessExists($process) Then Run($exe) ; checks if process exists.. If not, it will Run the process $StartTimer = TimerInit() ; Reset the timer since the script just ran EndFunc ;==>Checkprocess AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DEVIOUZ Posted October 16, 2007 Author Share Posted October 16, 2007 Oooh, Nice spot Foy Meanwhile, i have complete this script myself, it is 4 lines. I might aswell give it to you (But for future reference, Helpfile) While 1 ; Opens up a WHILE loop, with 1 as a constant, so it is infinite If Not ProcessExists("notepad.exe") Then Run("notepad.exe") ; if the process of notepad.exe doesn't exist, it starts it Sleep (10) ; Puts the script to sleep for 10 milliseconds so it doesn't chew CPU power WEnd ; Closes the loop, tells it to go back to the beginning wow thanks for such fast replies guys.. ok so when then process gets ran i also need the Autoit.exe to terminate itself as well at the same it executes the process..how would i do that..?? I remember in batch code it would look like this ""START SYSTEM.EXE && EXIT"" SO HOW WOULD I DO THIS IN AUTOIT...??? If Not ProcessExists("SYSTEM.EXE") Then RUN("SYSTEM.EXE") && EXIT Link to comment Share on other sites More sharing options...
DEVIOUZ Posted October 16, 2007 Author Share Posted October 16, 2007 anybody know..?? once the SYSTEM.EXE is ran i want the AutoIt.exe to Exit.. how would i do this..?? Link to comment Share on other sites More sharing options...
rasim Posted October 16, 2007 Share Posted October 16, 2007 Opt("RunErrorsFatal", 0) While 1 If Not ProcessExists("notepad.exe") Then Run("notepad.exe") If Not @error Then Exit EndIf Sleep (10) WEnd Link to comment Share on other sites More sharing options...
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