Jump to content
Sign in to follow this  
DEVIOUZ

If Process Not Exist then Start It...?

Recommended Posts

DEVIOUZ

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

Share this post


Link to post
Share on other sites
tAKTelapis

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.

Share this post


Link to post
Share on other sites
Foy

or click the knowledge is power link in tAK's siggy. :)

Share this post


Link to post
Share on other sites
tAKTelapis

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

Share this post


Link to post
Share on other sites
DW1

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

Share this post


Link to post
Share on other sites
DEVIOUZ

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

Share this post


Link to post
Share on other sites
DEVIOUZ

anybody know..??

once the SYSTEM.EXE is ran i want the AutoIt.exe to Exit..

how would i do this..??

Share this post


Link to post
Share on other sites
rasim

Opt("RunErrorsFatal", 0)

While 1
    If Not ProcessExists("notepad.exe") Then
        Run("notepad.exe")
        If Not @error Then Exit
        EndIf
        Sleep (10)
    WEnd

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.