meb

Is this the right way to restart a program every so often?

meb
Jan 7th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. ;
  2. ; AutoHotkey Version: 1.x
  3. ; Language: English
  4. ; Platform: WinXP/7
  5. ; Author: studotwho
  6. ;
  7. ; Script Function:
  8. ; Restarts the iTeleportConnect service if it hasn't started - this usually happens if your
  9. ; wireless network interface hasn't started when iTC tries to connect.
  10. ;
  11. ; This script loops every (45) seconds to determine if iTC is running or not, and restarts it if it's not.
  12. ;
  13.  
  14. #SingleInstance, force
  15. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  16. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  17.  
  18. iTC_EXE = G:\PortableApps\TexterPortable\App\texter\texter.exe
  19. iTC_Path = G:\PortableApps\TexterPortable\App\
  20. iTC_imgName =texter.exe
  21.  
  22. loop {
  23. sleep 45000
  24. Process, Exist, %iTC_imgName% ; check to see if texter.exe is running
  25. If (ErrorLevel = 0) ; If it is not running
  26. {
  27. Run, %iTC_EXE%, %iTC_Path%, hide
  28. }
  29. Else ; If it is running, ErrorLevel equals the process id for the target program (Printkey). Then do nothing.
  30. {
  31. sleep 5
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment