?
Solved

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

Posted on 2014-11-23
10
Medium Priority
?
499 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 20

Assisted Solution

by:Peter Hutchison
Peter Hutchison earned 500 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 70

Assisted Solution

by:Qlemo
Qlemo earned 500 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 1000 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
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 
LVL 70

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 70

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 1000 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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

A small collection of useful tips and tricks for Windows 10 users that I decided to write as a result of recent questions that were asked and answered at Experts Exchange. Two short video tutorials included. Enjoy..
Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

765 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