Re: getting users to logoff



On Jan 17, 12:34 pm, "Mathieu CHATEAU" <gollum...@xxxxxxx> wrote:
Here is the vbscript.
Hopes that newsgroups reader won't kill the carrier returns...

Just change:
 ou=Mystations,dc=mydomain,dc=com to match your OU.
C:\Scripts\LogOff\LogOff.log to a correct path for the log.
This will logoff users on workstations

Const ForWriting = 2
strComputerContainer = "ou=Mystations,dc=mydomain,dc=com"

Set objContainer = GetObject("LDAP://"; & strComputerContainer)
objContainer.Filter = Array("Computer")

Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile ("C:\Scripts\LogOff\LogOff.log",
ForWriting)
Set StdOut = WScript.StdOut
Set objShell = CreateObject("WScript.Shell")

On Error Resume Next

For Each objComputer In objContainer

 strComputer = Split(objComputer.Name, "=")(1)

 Set objScriptExec = objShell.Exec("ping " & strComputer)
 strPingResults = LCase(objScriptExec.StdOut.ReadAll)
 objFile.Write (Now & VbCrLf)

 If InStr(strPingResults, "reply from") Then
  objFile.Write ("Ping " & strComputer & " OK" & VbCrLf)
  Err.Clear
  Set objWMIService = GetObject("winmgmts:" & _
   "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")

  If Err.Number Then
   objFile.Write ("Acces WMI " & strComputer & " Error" & VbCrLf)
   objFile.Write ("Type d'Erreur : " & Err.Number & ": " & Err.Description &
VbCrLf)
   Err.Clear
  Else

Const SHUTDOWN = 4
objFile.Write ("Acces WMI " & strComputer & " OK" & VbCrLf)
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(shutdown)}!\\" & strComputer &
"\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
    ObjOperatingSystem.Win32Shutdown(SHUTDOWN)
Next

  End If
 Else
objFile.Write ("Ping " & strComputer & " Error" & VbCrLf)
 End If
Next
objFile.Close

--
Cordialement,
Mathieu CHATEAU
English blog:http://lordoftheping.blogspot.com
French blog:http://www.lotp.fr

"Computerguy" <phil2...@xxxxxxxxx> wrote in message

news:43d4a82b-b658-427b-a9bb-c7e9eef2a901@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jan 14, 1:45 pm, "Mathieu CHATEAU" <gollum...@xxxxxxx> wrote:





Hello,

this is not really a security issue, but more a functionnal issue.
Roaming profile won't get updated, as it is updated at logoff.

We use a vbscript to reboot stations, which force logoff on the way.
You may change the code to only logoff without shutting down the pc
Are you intereseted in ?

--
Cordialement,
Mathieu CHATEAU
English blog:http://lordoftheping.blogspot.com
French blog:http://www.lotp.fr

"Computerguy" <phil2...@xxxxxxxxx> wrote in message

news:3f7cd77b-bb0f-42c5-a1cb-d5235b4495bf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Is there any security threat to the following ?
- windows xp2 is locked (have to enter Ctrl+Alt+Del)
- servers setup to disconnect users at 10:00 PM

For electricity savings reasons we are starting to request users
logoff and shutdown at the end of the day. Right now we have users
who forget to logoff, but their PC will go to the Windows XP locked
screen. If we are in the wrong forum please let us know to repost.
Thanks.- Hide quoted text -

- Show quoted text -

Mr. Chateau,

   We are interested in anything to get staff to exit the network.  I
almost forget we have files synching at logoff to their directory and
if they never logoff.....   We have Altiris and tried assigning a job
to restart at 10:00 PM, but when users do shutdown they would come in
the next day and after powering on the computer they are greeted by
the same shutdown job that powers off their computer.  At first we
were looking for software.  We would welcome a script to somehow
remove users from the network at a certain time.- Hide quoted text -

- Show quoted text -

Thank you, we will give it a try. Much appreciated.
.



Relevant Pages

  • Re: getting users to logoff
    ... as it is updated at logoff. ... logoff and shutdown at the end of the day. ... If the power bill is paid from *your* ... since you are getting no cooperation from users to shutdown their computers ...
    (microsoft.public.windows.server.security)
  • Re: getting users to logoff
    ... as it is updated at logoff. ... logoff and shutdown at the end of the day. ... If the power bill is paid from *your* ... since you are getting no cooperation from users to shutdown their computers ...
    (microsoft.public.windows.server.security)
  • Re: using the shutdown command to forcefully log off an account ?
    ... > using the shutdown command to ... > something like this in both limited accounts and the guest account. ... just logging in again after the logoff either. ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windowsxp.newusers)
  • Re: using the shutdown command to forcefully log off an account ?
    ... > using the shutdown command to ... > something like this in both limited accounts and the guest account. ... just logging in again after the logoff either. ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windowsxp.security_admin)
  • Re: using the shutdown command to forcefully log off an account ?
    ... > using the shutdown command to ... > something like this in both limited accounts and the guest account. ... just logging in again after the logoff either. ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.windowsxp.help_and_support)