dragonslayer49
IS-IT--Management
Do you know where I can find a log off script which will automatically logoff a user after certain time limit.
Your help will be greatly appreciated.
Your help will be greatly appreciated.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[green]
'==========================================================================
'
' NAME: TimedLogoff.vbs
'
' AUTHOR: Mark D. MacLachlan, The Spider's Parlor
' COPYRIGHT: (c) 2008 All Rights Reserved
' DATE : 10/20/2008
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
' ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
' THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
' PARTICULAR PURPOSE.
'
' IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS
' BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
' DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
' WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
' ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
' OF THIS CODE OR INFORMATION.
'
' COMMENT:
'
'
'==========================================================================
[/green]
On Error Resume Next
Const FORCE = 4
SessionAllowedHours = [red]2[/red] [green]'hours[/green]
SessionAllowedMinutes = [red]30[/red][green]'minutes[/green]
LogonTime = Now
LogoffTime = DateAdd("h",SessionAllowedHours, LogonTime)
LogoffTime = DateAdd("n",SessionAllowedMinutes, LogoffTime)
WScript.Echo "You will be automatically logged off at:" & LogoffTime
Do While Now < LogoffTime
WScript.Sleep 300
Loop
[green]
'Time to log off
[/green]
mname = "."
Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate,(RemoteShutdown)}//" & mname).ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each OpSys In OpSysSet
OpSys.Win32Shutdown FORCE
Next