Schedule a task for when computer is idle

Dracula28Dracula28 Member Posts: 232
Hello guys,

I'm having difficulties scheduling a task for when computer is idle. What I want to do is run a task after the computer has been idle for five minutes. I've tried creating a scheduled task in different ways, which will do this, but to no avail.

I go to Task scheduler to create a task:

General Tab
Give the task a name, put the check box to run with the highest priv., and configure it for Win 7.

Triggers Tab
New, Begin the task on idle, Repeat task for 15 minutes indefinitely, Enabled.

Action Tab
Start whatever program.

Conditions Tab

Start the task only if computer is idle for 5 minutes. Do not wait for idle.

The settings I have not described stay default.

Now from what I can gather from this is that every 15 minutes, the computer will run the task if the computer stays idle for 5 minutes. Say, I start the computer and leave it like that, then the task should run after 5 minutes. Then after 10 minutes, it will once again start checking to run the task.

But this just does not work. If I leave the computer idle for even 7 minutes after startup, nothing happens. What am I doing wrong?
Current certs: MCP (210) MCSA (270, 290, 291 and 680) MCTS (680, 640)

Comments

  • DevilsbaneDevilsbane Member Posts: 4,214 ■■■■■■■■□□
    I don't think you need that repeat task every 15 minutes.

    You just need to have the trigger to start the task. Also, check the logs. Maybe it isn't starting because user credentials are wrong. Or maybe the path to the application isn't valid. Log files will spell this out.
    Decide what to be and go be it.
  • Dracula28Dracula28 Member Posts: 232
    Devilsbane wrote: »
    I don't think you need that repeat task every 15 minutes.

    You just need to have the trigger to start the task. Also, check the logs. Maybe it isn't starting because user credentials are wrong. Or maybe the path to the application isn't valid. Log files will spell this out.

    Well, I tried the task now, and for some strange reason, now it did run. The path is just fine, because I can always just click run to test the task. Also, the user credentials really should not be an issue, as I am just trying to kill some processes, and start a new process. The processes that I am trying to kill are just some apps that are running. And the task I am starting is iexplore.exe (IE9). The batch file itself works just fine, as I have tested it several times. Logged on with different users.

    What exactly does "Repeat task for 15 minutes indefinitely" do? I am assuming that unless I set this option, the task will only run once?

    I also am not quite getting the "Start the task only if computer is idle for 5 minutes". "Do not wait for idle". options, and technet really does not explain that very well.

    Perhaps the reason I am having trouble running the task is because Win7 needs to have its cpu usage lower than 10%, for it to consider the computer in idle state?
    Current certs: MCP (210) MCSA (270, 290, 291 and 680) MCTS (680, 640)
  • Dracula28Dracula28 Member Posts: 232
    And now its not working anymore. Quite frankly, I am getting sick of the task scheduler. Is there any way I can run a batch file the moment the screen saver is launched? That way I can just set the screen saver to kick in after five minutes, and have this batch file kill those processes.

    Basically its a kiosk pc, where the customer wants the processes to be killed and iexplore to start with the start page after five minutes inactivity.
    Current certs: MCP (210) MCSA (270, 290, 291 and 680) MCTS (680, 640)
  • DevilsbaneDevilsbane Member Posts: 4,214 ■■■■■■■■□□
    "Idle" is based on no mouse/keyboard activity. User credentials are still important, the task has to run under someone. Even if the task was to run calc.exe (which I often use to test my schedules because it isn't going to break anything and makes it clear whether it worked) credentials are needed.

    I haven't done much work with scheduler in windows 7, so my thinking is mostly going off XP.
    Decide what to be and go be it.
  • Jander1023Jander1023 Member Posts: 160
    Try changing the User or Group to "SYSTEM" and check the run with highest privileges option. These options are available on the properties dialog for the task. Let me know if this works.
  • Dracula28Dracula28 Member Posts: 232
    Devilsbane, I understand that I need to provide user credentials, but what I meant is that it should not be necessary to provide admin credentials for this task.

    Jander1023, I tried to set the user as system, but still the task would not run properly. I think this has something to do with task scheduler wanting the cpu usage to be lower than 10% for it to run a task after x minutes of idle time. I don't know for sure though.

    But in any case, I got sick of the task scheduler, and have found a way around it. I downloaded a batch to exe converter Bat To Exe Converter , then converted the batch file to exe, renamed the .exe to .scr extension, and set the file as screensaver. Now the screen saver is absolutely awesome in every way possible, because it runs the task just as I want it to. :D

    Conclusion, Screen Saver is king, Task Scheduler is overrated (when it comes to running tasks after x minutes of idle time).
    Current certs: MCP (210) MCSA (270, 290, 291 and 680) MCTS (680, 640)
  • DevilsbaneDevilsbane Member Posts: 4,214 ■■■■■■■■□□
    Dracula28 wrote: »
    But in any case, I got sick of the task scheduler, and have found a way around it. I downloaded a batch to exe converter Bat To Exe Converter , then converted the batch file to exe, renamed the .exe to .scr extension, and set the file as screensaver. Now the screen saver is absolutely awesome in every way possible, because it runs the task just as I want it to. :D

    Never heard of this, but I will be certainly stealing it. Thanks for the heads up!
    Decide what to be and go be it.
  • Dracula28Dracula28 Member Posts: 232
    And if you want to have a regular screen saver, you can just have the batch call it up at the end (or at the start I presume) from c:\windows\system32\nameofscreensaver.scr. I must say I've learned a lot trying to create this Windows 7 kiosk. A lot of things that were never mentioned on the exam or the TK. It did come at the worst possible time though, as I was thinking of taking 640 next Wednesday, but have pretty much used last week just setting up and configuring a bunch of kiosks. Also, someone broke into my house this week, and stole some jewelry and cash (not much of the latter though).

    Btw, here is the batch file I've created (window will be minimized)
    if not "%minimized%"=="" goto :minimized
    set minimized=true
    start /min cmd /C "%~dpnx0"
    goto :EOF
    :minimized
    TASKKILL /F /IM nameoftask.exe /FI "STATUS eq RUNNING"
    TASKKILL /F /IM nameoftask.exe /FI "STATUS eq RUNNING"
    TASKKILL /F /IM nameoftask.exe /FI "STATUS eq RUNNING"
    start iexplore
    

    If you want to completely hide the cmd window from showing, you can have this vbs call up the batch file
    Const HIDDEN_WINDOW = 12
    
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objStartup = objWMIService.Get("Win32_ProcessStartup")
    
    Set objConfig = objStartup.SpawnInstance_
    objConfig.ShowWindow = HIDDEN_WINDOW
    Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
    errReturn = objProcess.Create("nameofbatchfile.bat", null, objConfig, intProcessID)
    

    Just remember to either put the batch file in c:\windows\system32, or edit the vbs to include the path where you want to call the batch file from. Obviously you can use this vbs to hide any process/application.
    Current certs: MCP (210) MCSA (270, 290, 291 and 680) MCTS (680, 640)
  • Jander1023Jander1023 Member Posts: 160
    Dracula28 wrote: »
    Devilsbane, I understand that I need to provide user credentials, but what I meant is that it should not be necessary to provide admin credentials for this task.

    Jander1023, I tried to set the user as system, but still the task would not run properly. I think this has something to do with task scheduler wanting the cpu usage to be lower than 10% for it to run a task after x minutes of idle time. I don't know for sure though.

    But in any case, I got sick of the task scheduler, and have found a way around it. I downloaded a batch to exe converter Bat To Exe Converter , then converted the batch file to exe, renamed the .exe to .scr extension, and set the file as screensaver. Now the screen saver is absolutely awesome in every way possible, because it runs the task just as I want it to. :D

    Conclusion, Screen Saver is king, Task Scheduler is overrated (when it comes to running tasks after x minutes of idle time).

    Well, sorry my suggestion didn't help. However, I'm glad you found an alternative solution. Unfortunately, task scheduler isn't covered in much detail on any of the Windows 7 certification tracks. I use task schedule at work but only for basic tasks that aren't idle time related.

    Now I'm curious how Win7 works with idle time and task schedules. I'll dig a little bit next week while at work, time permitting. If I find anything, I'll be sure to post it here.
Sign In or Register to comment.