#121681 - 2004-06-22 09:07 PM
forced logoff
|
dmarussi
Fresh Scripter
Registered: 2004-05-11
Posts: 15
|
i want to implement a script that will force all pc's to log off at around 3:00am everyday. i'm thinking that the best way to do this is to write a script that will first copy kix32.exe down locally to the pc, and then add a scheduled task (we're dealing with win2k pro and XP pro machines here) that will run the script the same time each night using KIX's LogOff command. i'm sure there's a better way to do this and i'm sure you people will find it... i'm open to suggestions, thanks in advance. -Dan
|
|
Top
|
|
|
|
#121688 - 2004-06-29 03:35 AM
Re: forced logoff
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
I have a scheduled task (generated by kix) that shuts the loacl PC down at 3:00am... but it does pop up a msgbox before hand to avert the shutdown, if it is in use at the time...
Code:
;? "Set Logoff Policy" $file ="%windir%\logoff.kix" $time ="0330" $days =1+2+4+8+16+32+64 ; m,t,w,th,f,sa,su $command="kix32.exe $file" $mstime ="********"+$time+"00.000000-240" ; MS notation for time yyyymmdd is passed with * $message='Click the OK Button, or the computer will shutdown in 30 seconds' $title ='Restart Warning from AHCA Information Technology' del $file ;delete this line after March 1, 2004
if not exist($file) $=open(1,$file,5) $=writeline(1,'$=setconsole("hide")'+@CRLF) $=writeline(1,'$box=messagebox("$message","$title",0+48+4096,30)'+@CRLF) $=writeline(1,'if $box=-1'+@CRLF) $=writeline(1,' $=shutdown("","The system is being shutdown",10,1,2)'+@CRLF) $=writeline(1,' endif'+@CRLF) $=writeline(1,''+@CRLF) $=close(1) endif $objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") if $objWMIService $colItems = $objWMIService.ExecQuery("Select * from Win32_ScheduledJob",,48) $taskexist=0 For each $objItem in $colItems if $objItem.Command = $command if $objItem.DaysOfWeek=$days if $objItem.StartTime=$mstime $taskexist=$objItem.JobId else $=$objItem.delete endif else $=$objItem.delete endif endif next if not $taskexist $runrpt = 0 ; boolean for run repeatedly $daymon = 0 ; used for specific dates $interact=1 ; boolean for interactive with desktop $objNewJob = $objWMIService.get("Win32_ScheduledJob") $errJobCreated = $objNewJob.Create($command,$mstime,$runrepeatedly,$days,$daymon,$interact) $objWMIService = 0 endif endif
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Henriques)
and 2516 anonymous users online.
|
|
|