Schedule Task for Logoff?

G

Guest

Is there a way to do a scheduled task for after a person logs off? Basically
I want to run this when nobody is logged on, and it must be run from an
administrator account. Is this possible?
Thanks,
Jason Ryon
 
T

Torgeir Bakken \(MVP\)

Jason said:
Is there a way to do a scheduled task for after a person logs off?
Basically I want to run this when nobody is logged on, and it must
be run from an administrator account. Is this possible?
Hi

Not directly, but you could create a scheduled task that with certain
intervals kicks off a script that checks if someone is logged on, and
if not, do whatever you need to be done.

Parsing the output of QWINSTA.EXE is an option, in this link there is
a VBScript that does exactly that:
http://groups.google.co.uk/[email protected]


Using WMI/VBScript should also work:

'--------------------8<----------------------

strComputer = "." ' " use "." for local computer

Set objWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colSessions = objWMI.ExecQuery _
("Select * from Win32_LogonSession Where LogonType=2 or LogonType=10")

If colSessions.Count = 0 Then
' No logged on user found, do something here
End If
'--------------------8<----------------------


WSH 5.6 documentation (local help file) can be downloaded
from here if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top