Jump to content

PCGuy84

Members
  • Posts

    4
  • Joined

  • Last visited

PCGuy84's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Sorry I had just adjusted the bottom it was the same as the original I sent. I added the Sleep(10000) and it helped no longer have the issue of it trying to open over and over, however now I'm finding that the first If statements seems to randomly close the processes. $StartTimer = TimerInit() ; Define the initial time we will be comparing to laterCheckprocess() ; Run our checkprocess() function on initial executeWhile 1 ; Infinite Loop Condition is always true, you can exit these loops with "ExitLoop" If TimerDiff($StartTimer) > 600000 Then ; Only run the conditional code if the difference in time is greater than 1 min (600000 Miliseconds) Checkprocess() EndIf Sleep(10) ; So we don't kill the CPUWEnd ; End of While LoopFunc Checkprocess()If Not ProcessExists("Process1.exe") Then ProcessClose("Process2.exe") And ProcessClose("Process3.exe")If Not ProcessExists("Process2.exe") Then ProcessClose("Process1.exe") and ProcessClose("Process3.exe")If Not ProcessExists("Process3.exe") Then ProcessClose("Process1.exe") and ProcessClose("Process2.exe")If Not ProcessExists("Process1.exe") and Not ProcessExists("Process2.exe") and Not ProcessExists("Process3.exe") Then Run("C:\Restart.bat"); if the processes don't exist, it starts the script Sleep(10000) ; So we don't kill the CPUEndFunc ;==>Checkprocess Due to the process closing issue even if the process did exist I tried another way. I don't have the issue with the program restarting however if one process is closed it does not close the other two I have to manually close them all to get it to then restart. $StartTimer = TimerInit() ; Define the initial time we will be comparing to later 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) > 20000 Then ; Only run the conditional code if the difference in time is greater than 1 min (20000 Miliseconds) Checkprocess() EndIf Sleep(100) ; So we don't kill the CPU WEnd ; End of While Loop Func Checkprocess() If Not ProcessExists("Process1.exe") Or Not ProcessExists("Process2.exe") Or Not ProcessExists("Process3.exe") Then ProcessClose("Process1.exe|Process1.exe|Process1.exe") Sleep(100) ; So we don't kill the CPU If Not ProcessExists("Process1.exe") And Not ProcessExists("Process2.exe") And Not ProcessExists("Process3.exe") Then Run("C:\Script.bat"); if the processes don't exist, it starts the script Sleep(10000) ; So we don't kill the CPU EndFunc ;==>Checkprocess
  2. Alright so it appears to be working except the batch script keeps opening over and over and over! Here is the end of the script If Not ProcessExists("Process1.exe") and Not ProcessExists("Process2.exe") and Not ProcessExists("Process3.exe") Then Run("C:\Restart.bat"); if the processes don't exist, it starts the scriptEndFunc ;==>Checkprocess I removed the - Sleep (10) ; Puts the script to sleep for 10 milliseconds so it doesn't chew CPU powerWEnd ; Closes the loop, tells it to go back to the beginning" part as it was giving a syntax error I still have the Sleep and WEnd at the top of the scrip within the timer area. It appears to do what I want it to do if all of the processes are closed it will open them all up and work, however if they are already open it is closing them and then just starts looping the start up of the batch file.
  3. That was simple enough just remove the "And"... Thanks for the quick response, will try to test it now!
  4. Hello, I'm trying to build a script that will check if 3 processes are running and if any one of the processes is not I want to close the other 2 and run a script to restart them. I'd like this to check the system every 10 minutes. I've used AutoIT in the past to automate application installs and basic things and my "coding" background is limited so most likely it's something stupid I am doing so I'm hoping for someone to steer me in the right direction. I've looked through the forums and google and was able to find some items to help such as the timer. I'll post what I have below. $StartTimer = TimerInit() ; Define the initial time we will be comparing to later 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) > 600000 Then ; Only run the conditional code if the difference in time is greater than 1 min (600000 Miliseconds) Checkprocess() EndIf Sleep(10) ; So we don't kill the CPU WEnd ; End of While Loop Func Checkprocess() If Not ProcessExists("Process1.exe") Then ProcessClose("Process2.exe") And ProcessClose("Process3.exe") If Not ProcessExists("Process2.exe") Then ProcessClose("Process1.exe") and ProcessClose("Process3.exe") If Not ProcessExists("Process3.exe") Then ProcessClose("Process1.exe") and ProcessClose("Process2.exe") If Not ProcessExists("Process1.exe") and Not ProcessExists("Process2.exe") and Not ProcessExists("Process3.exe") Then Run("C:\Restart.bat"); if the processes don't exist, it starts the script 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 EndFunc ;==>Checkprocess I get the following errors: Syntax error multi-line 'If' missing 'Then' - I get this after the first 3 "If" statements Syntax error - Statement cannot be just an expression. I get this after the "WEnd Statement" I'm assuming it does not like my "And" statements but I'm not really sure how else to do it. Again any helped would be appreciated. Thanks
×
×
  • Create New...