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.
Regards
Blacklisted Packager
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.
Regards
Blacklisted Packager
0 Comments
[ + ] Show comments
Answers (7)
Please log in to answer
Posted by:
anonymous_9363
16 years ago
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.
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
16 years ago
Posted by:
anonymous_9363
16 years ago
Posted by:
blacklisted_packager
16 years ago
Posted by:
anonymous_9363
16 years ago
Posted by:
blacklisted_packager
16 years ago
Just take a look at my script..
Dim objWMIService, objProcess, colProcess,pos,WshShell,command
Dim strComputer, strList,i
i=0
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
pos=InStr(objprocess.name,".scr")
if (pos>0 AND i=0) then
Wscript.sleep(300000)
i=i+1
call getproc
end if
if (pos>0 AND i=1) then
call rebootAction
end if
Next
Set colprocess=nothing
Set objwmiservice=nothing
Wscript.sleep(10000)
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
Wscript.quit
end Sub
Dim objWMIService, objProcess, colProcess,pos,WshShell,command
Dim strComputer, strList,i
i=0
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
pos=InStr(objprocess.name,".scr")
if (pos>0 AND i=0) then
Wscript.sleep(300000)
i=i+1
call getproc
end if
if (pos>0 AND i=1) then
call rebootAction
end if
Next
Set colprocess=nothing
Set objwmiservice=nothing
Wscript.sleep(10000)
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
Wscript.quit
end Sub
Posted by:
revizor
16 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.