Page 1 of 1 1
Topic Options
#121681 - 2004-06-22 09:07 PM forced logoff
dmarussi Offline
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
#121682 - 2004-06-22 09:36 PM Re: forced logoff
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Maybe you can do something like this from a central script...

shell '%comspec% /c shutdown -r -m \\remotecomputername -t 00 -f

I know its a reboot instead of logoff...But im not sure there would be any benefit to logoff rather than just reboot.

Top
#121683 - 2004-06-27 04:20 AM Re: forced logoff
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Geez, why so complicated?
Code:

$comps=COMNetView()
for each $comp in $comps
if $comp<>@WKSTA
$rc=fnWMIShutdown($comp,4)
endif
next
$rc=fnWMIShutdown(@WKSTA,4)

_________________________
There are two types of vessels, submarines and targets.

Top
#121684 - 2004-06-27 10:07 AM Re: forced logoff
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Perhaps that is okay, but may want to think about Servers. One may want to exclude Servers.
Top
#121685 - 2004-06-28 04:35 AM Re: forced logoff
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The original request was
Quote:

force all pc's to log off at around 3:00am everyday


which is being fulfilled by the script. Also, why would anybody be logged into a server anyway at 3am? Most server administration is done via remote connections anyway. And if certain computers or operating systems need to excluded then the example can easily be modified via OSID() or an ASCAN of excluded computer names in an array.


Edited by sealeopard (2004-06-28 04:44 AM)
_________________________
There are two types of vessels, submarines and targets.

Top
#121686 - 2004-06-28 07:12 AM Re: forced logoff
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Jens,

I know you worked in an Educational facility and you now work at some Company or Corporation so I'm not sure how large of a network you've had to help support, but in a large Network almost ALL the maintenance is done in the middle of the night by workers that are on duty to perform such activity and not all of it is done remotely.

As a whole our Company runs well over 1,000 Servers and a night crew typically handles the maintenance when and where possible. I know I'd be upset if I was working on something and some remote script was doing a force logoff on me.

Yes, you are correct about the request and I was not meaning anything towards you, just pointing out that it would definately include ALL systems in case the poster was not aware of such.

Top
#121687 - 2004-06-29 02:52 AM Re: forced logoff
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA


Yeah, I know, I'm nitpicking. Anyway, I'd improve the script so that if users in designated groups (e.g. "IT Maintenance") are logged into a computer (server, or even any computer) then the automatic logoff will not be triggered. UDFs for this are in the UDF Forum as well.
_________________________
There are two types of vessels, submarines and targets.

Top
#121688 - 2004-06-29 03:35 AM Re: forced logoff
Radimus Moderator Offline
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

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.034 seconds in which 0.017 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org