Solved

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

Posted on 2014-11-23
10
463 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
  • 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 68

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
 
LVL 68

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
Why won’t your email signature format correctly?

Struggling to get your corporate email signatures to format correctly? Does the logo keep resizing? Is the text appearing too big? What can you do to prevent this? Find out how you can save your signatures today.

 
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 68

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mac maintenance 6 35
DHCP Server 14 67
Windows Remote Desktop Connection - changing default port. 6 28
Why does my computer not boot? 12 30
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
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.

862 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now