Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Command Line Task Scheduler Power Options

28 Jul 2011   #1

Windows 7 Pro x86
Command Line Task Scheduler Power Options

Hi everyone,

I was trying to create a scheduled task via command line (schtask.exe) and I want it to run regardless of whether the user is on battery power or on AC power. I created an event and it runs fine on AC power but when I try it on the battery power, it doesn't work. I checked the task in the task scheduler and saw in the condition for my event the following options checked:
- Start the task only if the computer is on AC power
- Stop if the computer switches to battery power

After I create the task via command line, I can't modify the settings. Either way, I MUST only use the command line to create/modify the tasks. Is there any way to modify this variable? Or am I stuck on only having the task run on AC power?

Any help would be appreciated. Thanks!

My System SpecsSystem Spec
28 Jul 2011   #2
Bare Foot Kid
Microsoft MVP

W 7 64-bit Ultimate

Hello demonzrulaz, welcome to Seven Forums!

Perhaps I'm missing something, why can't you just use the Windows Task Scheduler for this?

Why MUST you use the command-line?
My System SpecsSystem Spec
28 Jul 2011   #3

XP Professional, 7 Professional

Why do you have to create the scheduled task in the command line? I can think of a couple reasons you might need to run it from the shell, but I'm interested to know why you can't create it from the wizard.

Also, have you checked out this site?

I don't see the function you are looking for off hand, but it's a good general guide to the schtasks.exe functions.
My System SpecsSystem Spec

19 Aug 2011   #4

Windows 7 Pro 64-bit

Okay, I appreciate that you guys want to make sure that demonzrulaz can't just use the GUI to set the power options, but here's a scenario for you: I'm trying to deploy software to 16 laptops with a script. The software needs to run as an administrative user in non-interactive mode on startup, but it needs to run regardless of whether or not the laptops are on AC. Now, is there a flag that hasn't been documented on Microsoft's site for power management? Or do I need to use some XML file? If so, what format does it need to be in (as there doesn't seem to be much documentation on that either)?
My System SpecsSystem Spec
12 Jul 2012   #5


In the case of randoogle, you can create your task in the GUI configuring your "on battery" settings. Then export that task to XML. On the command line, use the XML switch for your script.

I created a task with default power settings and then exported that task to XML. I then edited the power settings for that task and re-exported to XML. Comparing the files will show you the specific XML code that you can use:




My System SpecsSystem Spec

 Command Line Task Scheduler Power Options

Thread Tools

Similar help and support threads
Thread Forum
Task Scheduler stop programs when on battery power
I have a few programs on my computer that don't need to be running when I'm on battery power: Steam, DsiplayFusion, and a couple others. I could close them every time I don't need them, and then restart them once I'm plugged in, but I thought I might be able to use task scheduler to do that for me....
General Discussion
add folders in indexing options using registry or command line?
Hello, I'm trying to add folders in the indexing options by using either registry or command lines. This is for an unattended silent install. Any ideas ? Thanks.
Performance & Maintenance
Task scheduler unable to load task status/active tasks at startup.
My task manager is unable to load task status/active tasks at startup. I get the message: "The selected task "{0}" no longer exists. To see the current tasks, click Refresh." When I refresh I get the same message. I checked and found that under Microsoft the problem was in the defrag...
Performance & Maintenance
Outlook 2010 Command-Line Switches & options
Friends I have a situation similar to or exactly same as described in this long ugly chronicle, apparently a flaw in Outlook 2010 which MS doesn't or didn't ack Complete Outlook 2010 Lock-Up when accessing archive pst files What I specifically am asking help with is a command-line-based way of...
Browsers & Mail
Task Scheduler failing to start task with merged network locations
I have two routers I usually connect to (work and home) and each have wireless access. That means there are essentially 4 network locations I have listed. I have merged each respective network location (wired and wireless) into their own singular network location - "Work" and "Home". I also...
General Discussion
changing the power options from the command line
I have found a method from this very site which when this command, "C:\Windows\System32\powercfg.exe /setactive a1841308-3541-4fab-bc81-f71556f20b4a" is attached to a shortcut icon, will change the power plan when i click on the shortcut icon. What I require to do now is somehow issue that very...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 12:16.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App