dutchman2 Posted June 8, 2007 Posted June 8, 2007 Hi to all.I work as an administrator at a NOC (athens/greece)and wednesdays we perform series of updates plus full virus scan on the clients.Regardless of how many notifications I used there would be always somebody to ..shutdownSo after checking also the http://www.autoitscript.com/forum/lofivers...php?t38292.htmlwith a few additions it ended up in the form belowA couple of notes: Be sure to add a sleep timeout on querying for shutdown otherwise cpu usage climbs up to 50% I force a reboot since some progs (i.e) Avirus have already closed before the GUI I included it in the Domain logon script, but u can always psexec-it .....it works like a charm! The only bug i've found is that when connected through remote desktop, and choosing log-off (only the first time?) a message comes up "if you shutdown this computer remotely"and indeed if yes is pressed it shuts down. Is there a way i can at least find out if a user is connected remotely to ..exit ?Georgeexpandcollapse popupOpt("TrayIconHide", 1) #include <Date.au3> #include <GUIConstants.au3> ;** check for another instance running If WinExists("PreventShutdownGUI") then Exit EndIf ;**** get weekday during which to prevent shutdown from command line $res_day=0 if $CmdLine[0]<>0 then $res_day=$CmdLine[1] else Exit EndIf if ($res_day<1) OR ($res_day>7) then exit $pic=FileInstall("D:\My Pictures\Icons\36_1_30.gif",@TempDir&"\36_1_30.gif") $pic=@TempDir&"\36_1_30.gif" $pic2=FileInstall("D:\blonde_me.jpg",@TempDir&"\blonde_me.jpg") $pic2=@TempDir&"\blonde_me.jpg" $WM_QUERYENDSESSION = 0x0011 GUIRegisterMsg($WM_QUERYENDSESSION, "Cancel_Shutdown") GUICreate("PreventShutdownGUI") GUISetSTate(@SW_HIDE) Global $b_ShutdownInitiated = False While 1 Sleep (250) If $b_ShutdownInitiated = True then if $res_day=@WDAY then $counter=20; **countdown time $ttimer=$counter $file = FileOpen("\\xxx\shutdown_log.txt", 1) If $file <> -1 Then $time=_Now ( ) FileWrite($file, $time&" - "&@UserName&" on "&@ComputerName&" tried to shutdown" & @CRLF) FileClose($file) EndIf GUICreate("ATTENTION",350,300,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) ; will create a dialog box that when displayed is centered $font="Comic Sans MS" GUISetBkColor (0xE0FFFF) $n=GUICtrlCreatePic($pic,140,20, 64,46) $iWeekday = _DateToDayOfWeek (@YEAR, @MON, @MDAY) GUISetState () ;$widthCell=70 GUICtrlCreateLabel("Today is..."& _DateDayOfWeek($iWeekDay)&"!!!!",10,80,250,40) GUICtrlSetFont (-1,13, 500, 4, $font) GUICtrlSetColor(-1,0xff0000) GUICtrlCreateLabel("So this PC "&@crlf&"will ONLY reboot in",30,110,270,60) GUICtrlSetFont (-1,13, 500, 2, $font) GUICtrlSetColor(-1,0x7A67EE ) GUICtrlCreateLabel("seconds",60,170,110,180) GUICtrlSetFont (-1,13, 500, 2, $font) GUICtrlCreatePic($pic2,190,170, 70,70) $view_timer=GUICtrlCreateLabel($ttimer,30,170,30,180) GUICtrlSetFont (-1,13, 500, 2, $font) GUICtrlSetColor(-1,0xff0000) For $i = 1 to $counter sleep(1000) $ttimer=$ttimer-1 ;MsgBox(4096, "DEF:", $ttimer) GUICtrlSetData($view_timer,$ttimer) Next ;sleep (20000) shutdown(2);**REBOOT Exit Else Shutdown ( 1 ) ;*** not the given weekday so go on and shutdown... endif Exit; EndIf WEnd Func Cancel_Shutdown($hWndGUI, $MsgID, $WParam, $LParam) ;run(@ScriptDir & "\killpgm.exe") $b_ShutdownInitiated = True Return False EndFunc
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