VB /Batch script for checking if system is idle

Hi Everyone ,

I am trying to make a script which will trigger after a stipulated time say 20 minutes of no system activity (no user input or application running ).Can anyone guide me how to make such a script using vbs or batch.Thanks in advance.

Blacklisted Packager

0 Comments   [ + ] Show comments

Answers (7)

Posted by: anonymous_9363 13 years ago
Red Belt
I think you'd be extremely lucky to get ANY Windows system completely idle for 20 minutes - it's always up to SOMETHING! :)

Start here http://msdn.microsoft.com/en-us/magazine/cc302338.aspx, maybe...

Also, http://www.computerperformance.co.uk has some good WMI scripting examples.
Posted by: blacklisted_packager 13 years ago
Orange Belt
ummmmmmm...i guess i was not able to frame my query properly...
Lets say i leave my system unattended for 20 minutes ,a screensaver pops up and locks my desktop. I want to make a script which will trigger in a similar manner and instead of running a screensaver i want to do some action.
Posted by: anonymous_9363 13 years ago
Red Belt
...then have your script test in a loop for any process whose extension is .SCR. As soon as one starts, you know you can kick off your action.
Posted by: blacklisted_packager 13 years ago
Orange Belt
GMTA (great mind thinks alike ) .. before reading this post.. i made the script ..for checking the screensaver process but was not sure if its a best way ..
Posted by: anonymous_9363 13 years ago
Red Belt
I'd try not to tie it to a particular s/s, though. Keep it generic, to anything with a SCR extension.
Posted by: blacklisted_packager 13 years ago
Orange Belt
Just take a look at my script..

Dim objWMIService, objProcess, colProcess,pos,WshShell,command
Dim strComputer, strList,i
call getproc
sub getproc
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess in colProcess
if (pos>0 AND i=0) then
call getproc
end if
if (pos>0 AND i=1) then
call rebootAction
end if
Set colprocess=nothing
Set objwmiservice=nothing
call getproc
End Sub
sub RebootAction
set Wshshell= CreateObject("WScript.Shell")
command="shutdown.exe -s -t 30 -f"
Wshshell.run command,6,0
Set wshshell=nothing
end Sub
Posted by: revizor 13 years ago
Third Degree Blue Belt
.scr would also give you a false positive for the Windows logon process, among other things.

Are you looking for idle time for the system, or for a particular user? Think Terminal Server environment - 5 users logeed on, only one is currently active...
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ