Jump to content

If Process Not Exist then Start It...?


DEVIOUZ
 Share

Recommended Posts

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

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 by tAKTelapis
Link to comment
Share on other sites

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

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

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...