Solved

Can I use Win 7 Task Scheduler to run a program on shutdown?

Posted on 2014-11-23
10
483 Views
Last Modified: 2014-11-23
I know how to have Task Scheduler run a program.  Can I set it to run a program on shutdown, and then shutdown the system when the program completes?  Better yet, can I set Task Scheduler to run a program on shutdown, but only on certain days of the week and only after a chosen time of day?  I'd prefer to avoid using scripts.  Thanks.
0
Comment
Question by:sjw601
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 19

Assisted Solution

by:Peter Hutchison
Peter Hutchison earned 125 total points
ID: 40460745
You can run a task or program when a specific event occurs. For example, every time you shutdown your computer, it will generate an event e.g.

Event log: System
Source: User32
Event no: 1074

If you create a task based on that event, then yes, you can run a simple task then assuming it can finish on time before services and network is still up.
0
 
LVL 69

Assisted Solution

by:Qlemo
Qlemo earned 125 total points
ID: 40460777
The combined conditions cannot be used without checking in a script.

First option: A GPO shutdown script (http://technet.microsoft.com/en-us/library/cc770300.aspx) allows for delaying the shutdown process until the script has finished.

Second option: Setup a event triggered task as stated above. The task cannot delay shutdown, though, and might not be able to complete.

In both cases you need to check for other conditions yourself. Date arithmetics are best done in VBS or PowerShell, a .cmd batch is not suited well.
0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 250 total points
ID: 40460783
You could schedule a task based on the shutdown event,
schtasks /Create /RU "username" /RP "password" /SC ONEVENT /D Mon, Wed, Fri /ST 23:59 /TN "Taskname" /TR c:\path-to-program\program.exe"

However in looking at what you are asking, there are some concerns:

Better yet, can I set Task Scheduler to run a program on shutdown, but only on certain days of the week and only after a chosen time of day

You are asking for a level of granularity that is best served with a scripted solution.

First what if the task is set to trigger on the day at the time but no shutdown event is sent ?
Or an event is sent but the time and day criteria are not met ?

What you need would best be served with a solution than can implement logic and also abort any current shutdown request to allow your program to complete then run the shutdown itself.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 69

Expert Comment

by:Qlemo
ID: 40460804
becraig, I don't think you can combine /SC ONEVENT with /D. The Wizard definitely does not allow that.
0
 
LVL 29

Expert Comment

by:becraig
ID: 40460813
That is the point I am making Qlemo in the little bit of chatter beneath it:
First what if the task is set to trigger on the day at the time but no shutdown event is sent ?
Or an event is sent but the time and day criteria are not met ?

Simply stating that the options exist but would not work as expected due to the absence of conditional logic.
0
 

Author Comment

by:sjw601
ID: 40460881
Thanks, everyone!  I think I'll go with a simple shutdown task/script and ignore date and time.  One more question: Task Scheduler will run the program, "xyz.exe."  However, doing so opens the program, but does not actually run it by, for example, clicking "run."  Is there a parameter or something that I can add to the exe or Task Scheduler to make it open the program and invoke "run," so that the program actually accomplished its mission?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40460906
Of course Task Scheduler runs the application. Are talking about a GUI?
0
 
LVL 29

Accepted Solution

by:
becraig earned 250 total points
ID: 40460907
If I am reading your question correctly, you want to know how to make your program do a specific thing instead of just opening ?

Without more details on what program you are calling there is no easy way to answer that.

I would think there should be parameters you can include in your program to call whatever it is you want to do, however more info on exactly what you plan to cal will help tremendously.
0
 

Author Closing Comment

by:sjw601
ID: 40461024
Thanks everyone.  Yes, the program is a GUI.  I'm in touch with the publisher to see whether I can add a parameter or something so that the opens and runs.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question