WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Win7

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

System Idle

 Keywords: System Idle Last Activity Mouse Keystroke Win7 GetLastInputInfo Task Scheduler Service Named Pipes.

Question:

I'm looking for a way to tell how long a Windows 7 or XP System has been idle. I had a great script to notify a user of an upcoming forced reboot that included a countdown timer, only to discover that Task Scheduler can no longer interact with the desktop in Vista/Windows 7. So now I need to make sure there has been at least 45 minutes of inactivity before forcing a reboot. I don't want to have to wait for 45 minutes if the system has already been inactive for longer.

Answer:

The GetLastInputInfo Api looks interesting. It retrieves the time of the last input event of the current users session. Looks like a UDF calling that function has already been written. http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/DllCall~Information+Check~for~Input~Idle~-~No~User~Input.txt

User Reply:

I had seen that function info. Unfortunately it is session specific. According to MSDN: "GetLastInputInfo does not provide system-wide user input information across all running sessions. Rather, GetLastInputInfo provides session-specific user input information for only the session that invoked the function."

As my script is going to be launched via the Task Scheduler, I don't think I'll be able to get a valid time using this function that I can use to make sure the system is not in use and active.

Answer:

Nothing built into WinBatch to handle this. The trick will be to figure out how it can be accomplished programmatically, then attempt to apply that technique using WinBatch.

Here is a few ideas you migh want to pursue.


Article ID:   W18440
Filename:   System Idle.txt
File Created: 2014:07:18:09:51:40
Last Updated: 2014:07:18:09:51:40