kylomas Posted February 7, 2014 Share Posted February 7, 2014 camilla, The following reads event records for event service start (corresponds closely to Windows startup). Two variables allow you to designate how many times the pc is allowed to be restarted ($Num_Restarts_Allowed) in what time frame ($Monitoring_Period). Tested on Win7 (64bit) under Autoit 3.3.10+ expandcollapse popup#include <EventLog.au3> #include <array.au3> #include <MsgBoxConstants.au3> OnAutoItExitRegister('_fini') Local $hEventLog, $aEvent, $cnt = 0, $dte local $Num_Restarts_Allowed = 1 ; # of restarts allowed for monitoring period local $Monitoring_Period = 24 ; time period for # of restarts in hours $hEventLog = _EventLog__Open("", "System") if $hEventLog = 0 then ConsoleWrite('Log failed to open' & @LF) Exit endif while 1 $aEvent = _EventLog__Read($hEventLog, True, False) if $aEvent[0] = false then exit if $aEvent[6] = 6005 then $dte = stringright($aEvent[4],4) & '/' & StringLeft($aEvent[4],2) & '/' & stringmid($aEvent[4],4,2) & ' ' & stringleft($aEvent[5],8) $cnt += 1 if _datediff('h',$dte,_nowcalc()) > $Monitoring_Period then exit endif if $cnt > $Num_Restarts_Allowed then if _datediff('h',$dte,_nowcalc()) < $Monitoring_Period then if msgbox($MB_OKCANCEL,'Restart Limit Exceeded','Reply:' & @crlf & ' [OK] to continue' & @crlf & ' [Cancel] to abort restart') = $idOK then exit Else ; ; do denial routine here, perhaps shutdown ; EndIf endif EndIf endif wend func _fini() _EventLog__Close($hEventLog) endfunc This is only a skeleton of how this might be done and probably needs more error checking and testing. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted February 7, 2014 Share Posted February 7, 2014 Of course that script will have to be ran after each reboot. Probably need to run such a program as a service. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
camilla Posted February 7, 2014 Author Share Posted February 7, 2014 kylomas JohnOne thank you ,but i see you didn't get my idea it is very easy my script will run a messagebox only after 3 times of computer restart less than that it will not run the message box this explains everything Link to comment Share on other sites More sharing options...
kylomas Posted February 7, 2014 Share Posted February 7, 2014 (edited) thank you ,but i see you didn't get my idea Hmmm, I see, Good Luck, kylomas Edited February 7, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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