1

On Windows 7, is it possible to set the "Allow task to be run on demand" attribute from the command line when creating a scheduled task to be run on another Windows 7 computer (actually 9 others in a workgroup environment)?

This task needs to be run both as a daily scheduled task and on demand. Setting a nonexistent date or trigger is not going to work, as I've seen suggested here and elsewhere.

I'd prefer not to use XML. Powershell is acceptable as long as it fits on a command line and isn't a full script.

I'm puzzled by this article: "The Scheduled Task module first appeared with Windows PowerShell 3.0 in Windows 8 and Windows Server 2012." Is it available on Windows 7?

Thanks in advance.

Dan
  • 51
  • 1
  • 5
  • The New-ScheduledTask command was introduced in Windows 8, that article is correct https://technet.microsoft.com/en-us/library/jj649810%28v=wps.630%29.aspx?f=255&MSPPError=-2147217396 – Drifter104 Jun 09 '16 at 15:26

2 Answers2

1

A few tidbits of information I've picked up since I posted the original question.

First, Powershell version 4, which has the best implementation of creating scheduled tasks, and includes ALL the options in the GUI, is available as a download for Windows 7 here. They're actually up to v5, but you have to install v4 first, you can't go from 2 (the one Windows 7 SP1 comes with) directly to 5. So I'll stick with 4, it has what I need.

Second, it's actually quite easy to schedule tasks in Powershell, see this article.

And finally, it's a good idea to write a wrapper DOS batch script for calling Powershell, as described here. No need for signed scripts and other annoyances. So that takes care of my reluctance to use Powershell.

Well..... sort of.....

Dan
  • 51
  • 1
  • 5
0

You need to add the task with a daily scheduled event from the standard command line; once the task is set to run daily, just verify that the other people have permissions to access that task over the network.

schtasks /Create /S <remote computer name> /SC DAILY /MO 1 /ST <HH:mm start time> /TN "<task name>" /TR "<command line to execute>"

1) The /S <remote computer name> is nly needed if running the command from a different computer.
2) The /TR portion of the command needs to use a path that is relative and visible from the computer service account that will execute this scheduled task. Network locations may need domain permissions for the computer $HOSTNAME or the task may fail.

Once the task is created, you can run it any time through the task manager or with the following command:

schtasks /Run /S <remote computer name> /TN "<task name>"
CoveGeek
  • 186
  • 1
  • 7