lafafmentvotre Posted March 20, 2012 Share Posted March 20, 2012 (edited) Hi everybody and sorry for my bad english I want to know how to restart automatically a program who was closed. I tested the service_create who runs a script. This script must restart a program but i don't know what to insert in this script, like "if my process stops restart this process" with a loop who always running Thanks for help and the advice Edited March 20, 2012 by lafafmentvotre Link to comment Share on other sites More sharing options...
Chimaera Posted March 20, 2012 Share Posted March 20, 2012 (edited) Maybe something like this? If Not ProcessExists("file to watch.exe Or the PID") Then sleep(2000) ShellExecute("file to watch.exe") EndIf prob not exactly right but it will get you started. You will probably need it within a while - wend loop to make it right Edited March 20, 2012 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
lafafmentvotre Posted March 21, 2012 Author Share Posted March 21, 2012 HelloI made this script (that works without error)#NoTrayIcon #region AUTOIT VARIABLES #endregion #region SCRIPT VARIABLES Local $bill_process='Bill_Redirect_Serial_to_KB.exe' Local $win_process='winlogon.exe' Local $exe='C:\PROGRA~2\BILLPR~1\BILLRE~1\BILL_R~1.EXE' #endregion #region SCRIPT Check_Bill() #endregion #region FUNCTIONS Func Check_Bill() Do If ProcessExists($win_process) Then If ProcessExists($bill_process)=0 Then ShellExecute($exe) EndIf EndIf Until Not ProcessExists($win_process) EndFunc #endregionAnd i used this script to create a service who uses this previous script#region AUTOIT VARIABLES #include <Services.au3> #endregion #region SCRIPT VARIABLES Local $process='Bill_Redirect_Serial_to_KB.exe' Local $exe='C:\PROGRA~2\BILLPR~1\BILLRE~1\BILL_R~1.EXE' Local $sServiceName='BillServices' Local $sDisplayName='Bill Services' Local $iServiceType=$SERVICE_WIN32_OWN_PROCESS Local $iStartType=$SERVICE_AUTO_START Local $iErrorControl=$SERVICE_ERROR_NORMAL Local $sBinaryPath='C:\Program Files (x86)\BillProduction\Bill Redirect Serial COM Port to Keyboard Buffer\Bill_Redirect_W7_Services.exe' #endregion _Service_Create($sServiceName, $sDisplayName, $iServiceType, $iStartType, $iErrorControl, $sBinaryPath) ;~ _Service_Delete($sServiceName)But the service doesn't start with ErrorDo you have an idea ? Link to comment Share on other sites More sharing options...
timi1014 Posted March 21, 2012 Share Posted March 21, 2012 Don´t do such heavy script keep it simple While 1 if ProcessExists("firefox.exe") Then Sleep(2000) ElseIf Not ProcessExists("firefox.exe") Then ShellExecute("firefox.exe","",@ProgramFilesDir & "Mozilla Firefoxfirefox.exe") EndIf WEnd If you want you can put in hotkeysend with exit func. Link to comment Share on other sites More sharing options...
lafafmentvotre Posted March 21, 2012 Author Share Posted March 21, 2012 Hello I modified like this Opt("TrayIconHide", 1) #region AUTOIT VARIABLES #endregion #region SCRIPT VARIABLES Local $bill_process='Bill_Redirect_Serial_to_KB.exe' Local $exe='C:\PROGRA~2\BILLPR~1\BILLRE~1\BILL_R~1.EXE' #endregion #region SCRIPT While 1 If ProcessExists($bill_process) Then Sleep(1000) ElseIf Not ProcessExists($bill_process) Then ShellExecute($exe,'') EndIf WEnd #endregion But my Service doesn't work; I have the same error 1053 Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 21, 2012 Share Posted March 21, 2012 Does this help - service start error 1053 at DuckDuckGo? - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Bert Posted March 21, 2012 Share Posted March 21, 2012 Before we go further, why do you need to make sure you have your program restarted if it was closed? I have found in many cases what I refer to as a "Guard" script is usually used for maulware to make sure the maulware stays running. I know there are legit reasons also using the "guard" method to keep an application running but it would be helpful for you to tell us what you have in mind. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
lafafmentvotre Posted March 21, 2012 Author Share Posted March 21, 2012 In fact, my application closes after 30 minutes, and I manage people ask me that this application will not close (hard for them). I will not put my srcipt as a service, I will add it to the computer startup waiting for something better. This is not a problem too. In any case thank you for the help on this. See you soon 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