28 April, 2016

Simple logoff script with cancel prompt and timeout

Hi,

I looked for a way to logoff my kids session on my home PC and it seems that you only have it on Active Directory settings...

So I wrote a VB script and scheduled it to run under my kids username everyday at 23:00...

This will prompt the user if he wants to cancel the logoff and if not answered in 30 seconds (you can change it) will logoff.

Scheduled it for 23:00, 00:00, 01:00 ......

====================================================

Option Explicit
Dim objShell, intLogoff, strLogoff

set objShell = CreateObject("WScript.Shell")
intLogoff = (objShell.Popup("Cancel logoff ?",30,"Logoff",0))
If intLogoff = 1 Then
'Abort Logoff
'Wscript.echo "Login off Canceled"
Else
'Logging off
'Wscript.echo "Login off"
strLogoff = "logoff"
set objShell = CreateObject("WScript.Shell")
objShell.Run strLogoff, 0, false
End if

Wscript.Quit

===================================================

Enjoy...