@lppx/taskmgr 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -126
- package/TaskScheduler.2.12.2/TaskService.md +71 -71
- package/TaskScheduler.2.12.2/lib/net45/Microsoft.Win32.TaskScheduler.xml +7855 -7855
- package/Templates//344/274/221/347/234/240/350/204/232/346/234/254.ps1 +2 -2
- package/Templates//345/200/222/350/256/241/346/227/266/344/274/221/347/234/240/350/204/232/346/234/254.ps1 +68 -68
- package/Templates//345/200/222/350/256/241/346/227/266/345/205/263/346/234/272/350/204/232/346/234/254.ps1 +66 -66
- package/bin/run.js +0 -0
- package/dist/commands/tsk/add.d.ts +2 -1
- package/dist/commands/tsk/add.js +25 -6
- package/dist/commands/tsk/list.js +1 -0
- package/dist/hooks/init.js +1 -0
- package/oclif.manifest.json +26 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,48 +1,33 @@
|
|
|
1
|
-
@lppx/taskmgr
|
|
2
|
-
=================
|
|
3
|
-
|
|
4
|
-
定时任务管理器
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[](https://oclif.io)
|
|
8
|
-
[](https://npmjs.org/package/@lppx/taskmgr)
|
|
9
|
-
[](https://npmjs.org/package/@lppx/taskmgr)
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
@lppx/taskmgr
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
定时任务管理器
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
[](https://oclif.io)
|
|
8
|
+
[](https://npmjs.org/package/@lppx/taskmgr)
|
|
9
|
+
[](https://npmjs.org/package/@lppx/taskmgr)
|
|
10
|
+
|
|
11
|
+
|
|
12
12
|
<!-- toc -->
|
|
13
13
|
* [Usage](#usage)
|
|
14
14
|
* [Commands](#commands)
|
|
15
|
-
<!-- tocstop -->
|
|
16
|
-
|
|
17
|
-
* [Commands](#commands)
|
|
18
|
-
<!-- tocstop -->
|
|
19
|
-
# Usage
|
|
15
|
+
<!-- tocstop -->
|
|
16
|
+
# Usage
|
|
20
17
|
<!-- usage -->
|
|
21
18
|
```sh-session
|
|
22
19
|
$ npm install -g @lppx/taskmgr
|
|
23
20
|
$ tm COMMAND
|
|
24
21
|
running command...
|
|
25
22
|
$ tm (--version)
|
|
26
|
-
@lppx/taskmgr/0.
|
|
23
|
+
@lppx/taskmgr/0.1.0 linux-x64 node-v24.14.0
|
|
27
24
|
$ tm --help [COMMAND]
|
|
28
25
|
USAGE
|
|
29
26
|
$ tm COMMAND
|
|
30
27
|
...
|
|
31
28
|
```
|
|
32
|
-
<!-- usagestop -->
|
|
33
|
-
|
|
34
|
-
$ npm install -g @lppx/taskmgr
|
|
35
|
-
$ tm COMMAND
|
|
36
|
-
running command...
|
|
37
|
-
$ tm (--version)
|
|
38
|
-
@lppx/taskmgr/0.0.0 linux-x64 node-v20.20.1
|
|
39
|
-
$ tm --help [COMMAND]
|
|
40
|
-
USAGE
|
|
41
|
-
$ tm COMMAND
|
|
42
|
-
...
|
|
43
|
-
```
|
|
44
|
-
<!-- usagestop -->
|
|
45
|
-
# Commands
|
|
29
|
+
<!-- usagestop -->
|
|
30
|
+
# Commands
|
|
46
31
|
<!-- commands -->
|
|
47
32
|
* [`tm autocomplete [SHELL]`](#tm-autocomplete-shell)
|
|
48
33
|
* [`tm help [COMMAND]`](#tm-help-command)
|
|
@@ -123,7 +108,7 @@ EXAMPLES
|
|
|
123
108
|
$ tm scripts add ./script.ps1
|
|
124
109
|
```
|
|
125
110
|
|
|
126
|
-
_See code: [src/commands/scripts/add.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.
|
|
111
|
+
_See code: [src/commands/scripts/add.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.1.0/src/commands/scripts/add.ts)_
|
|
127
112
|
|
|
128
113
|
## `tm scripts list`
|
|
129
114
|
|
|
@@ -140,7 +125,7 @@ EXAMPLES
|
|
|
140
125
|
$ tm scripts list
|
|
141
126
|
```
|
|
142
127
|
|
|
143
|
-
_See code: [src/commands/scripts/list.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.
|
|
128
|
+
_See code: [src/commands/scripts/list.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.1.0/src/commands/scripts/list.ts)_
|
|
144
129
|
|
|
145
130
|
## `tm scripts open`
|
|
146
131
|
|
|
@@ -157,7 +142,7 @@ EXAMPLES
|
|
|
157
142
|
$ tm scripts open
|
|
158
143
|
```
|
|
159
144
|
|
|
160
|
-
_See code: [src/commands/scripts/open.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.
|
|
145
|
+
_See code: [src/commands/scripts/open.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.1.0/src/commands/scripts/open.ts)_
|
|
161
146
|
|
|
162
147
|
## `tm tsk add TASKNAME`
|
|
163
148
|
|
|
@@ -165,24 +150,25 @@ _See code: [src/commands/scripts/open.ts](https://github.com/lipanpan-hub/taskmg
|
|
|
165
150
|
|
|
166
151
|
```
|
|
167
152
|
USAGE
|
|
168
|
-
$ tm tsk add TASKNAME
|
|
169
|
-
[--start-when-available] [--stop-on-battery] [--time <value>] [--trigger
|
|
170
|
-
[--wake]
|
|
153
|
+
$ tm tsk add TASKNAME [-p <value> | | [--arguments <value> --path <value>]] [--description <value>]
|
|
154
|
+
[--hidden] [--start-when-available] [--stop-on-battery] [--time <value>] [--trigger
|
|
155
|
+
boot|daily|logon|monthly|once|weekly] [--wake]
|
|
171
156
|
|
|
172
157
|
ARGUMENTS
|
|
173
158
|
TASKNAME 任务名称
|
|
174
159
|
|
|
175
160
|
FLAGS
|
|
176
|
-
--
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
161
|
+
-p, --ps-script=<value> PowerShell 脚本路径,自动使用 powershell.exe 执行
|
|
162
|
+
--arguments=<value> 执行参数
|
|
163
|
+
--description=<value> 任务描述
|
|
164
|
+
--[no-]hidden 是否隐藏任务
|
|
165
|
+
--path=<value> 可执行文件路径
|
|
166
|
+
--[no-]start-when-available 错过启动时间后是否自动启动
|
|
167
|
+
--[no-]stop-on-battery 使用电池供电时是否停止任务
|
|
168
|
+
--time=<value> [default: 09:00] 任务开始时间 (HH:mm)
|
|
169
|
+
--trigger=<option> [default: daily] 触发类型: daily, weekly, monthly, once, boot, logon
|
|
170
|
+
<options: boot|daily|logon|monthly|once|weekly>
|
|
171
|
+
--[no-]wake 是否唤醒计算机运行任务
|
|
186
172
|
|
|
187
173
|
DESCRIPTION
|
|
188
174
|
创建定时任务
|
|
@@ -197,9 +183,11 @@ EXAMPLES
|
|
|
197
183
|
$ tm tsk add psTask --path "powershell.exe" --arguments '-ExecutionPolicy Bypass -File "C:\scripts\cleanup.ps1"' --trigger daily
|
|
198
184
|
|
|
199
185
|
$ tm tsk add psInlineTask --path "powershell.exe" --arguments '-Command "Get-ChildItem C:\temp | Remove-Item -Recurse -Force"' --trigger weekly
|
|
186
|
+
|
|
187
|
+
$ tm tsk add scriptTask --ps-script "C:\scripts\cleanup.ps1" --trigger daily
|
|
200
188
|
```
|
|
201
189
|
|
|
202
|
-
_See code: [src/commands/tsk/add.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.
|
|
190
|
+
_See code: [src/commands/tsk/add.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.1.0/src/commands/tsk/add.ts)_
|
|
203
191
|
|
|
204
192
|
## `tm tsk del TASKNAME`
|
|
205
193
|
|
|
@@ -219,7 +207,7 @@ EXAMPLES
|
|
|
219
207
|
$ tm tsk del myTask
|
|
220
208
|
```
|
|
221
209
|
|
|
222
|
-
_See code: [src/commands/tsk/del.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.
|
|
210
|
+
_See code: [src/commands/tsk/del.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.1.0/src/commands/tsk/del.ts)_
|
|
223
211
|
|
|
224
212
|
## `tm tsk list`
|
|
225
213
|
|
|
@@ -230,7 +218,7 @@ USAGE
|
|
|
230
218
|
$ tm tsk list [--multi]
|
|
231
219
|
|
|
232
220
|
FLAGS
|
|
233
|
-
--multi 使用多行格式显示任务详情
|
|
221
|
+
--[no-]multi 使用多行格式显示任务详情
|
|
234
222
|
|
|
235
223
|
DESCRIPTION
|
|
236
224
|
列出所有定时任务
|
|
@@ -241,7 +229,7 @@ EXAMPLES
|
|
|
241
229
|
$ tm tsk list --multi
|
|
242
230
|
```
|
|
243
231
|
|
|
244
|
-
_See code: [src/commands/tsk/list.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.
|
|
232
|
+
_See code: [src/commands/tsk/list.ts](https://github.com/lipanpan-hub/taskmgr/blob/v0.1.0/src/commands/tsk/list.ts)_
|
|
245
233
|
|
|
246
234
|
## `tm version`
|
|
247
235
|
|
|
@@ -262,79 +250,4 @@ FLAG DESCRIPTIONS
|
|
|
262
250
|
```
|
|
263
251
|
|
|
264
252
|
_See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/2.2.37/src/commands/version.ts)_
|
|
265
|
-
<!-- commandsstop -->
|
|
266
|
-
* [`tm autocomplete [SHELL]`](#tm-autocomplete-shell)
|
|
267
|
-
* [`tm help [COMMAND]`](#tm-help-command)
|
|
268
|
-
* [`tm version`](#tm-version)
|
|
269
|
-
|
|
270
|
-
## `tm autocomplete [SHELL]`
|
|
271
|
-
|
|
272
|
-
Display autocomplete installation instructions.
|
|
273
|
-
|
|
274
|
-
```
|
|
275
|
-
USAGE
|
|
276
|
-
$ tm autocomplete [SHELL] [-r]
|
|
277
|
-
|
|
278
|
-
ARGUMENTS
|
|
279
|
-
[SHELL] (zsh|bash|powershell) Shell type
|
|
280
|
-
|
|
281
|
-
FLAGS
|
|
282
|
-
-r, --refresh-cache Refresh cache (ignores displaying instructions)
|
|
283
|
-
|
|
284
|
-
DESCRIPTION
|
|
285
|
-
Display autocomplete installation instructions.
|
|
286
|
-
|
|
287
|
-
EXAMPLES
|
|
288
|
-
$ tm autocomplete
|
|
289
|
-
|
|
290
|
-
$ tm autocomplete bash
|
|
291
|
-
|
|
292
|
-
$ tm autocomplete zsh
|
|
293
|
-
|
|
294
|
-
$ tm autocomplete powershell
|
|
295
|
-
|
|
296
|
-
$ tm autocomplete --refresh-cache
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.40/src/commands/autocomplete/index.ts)_
|
|
300
|
-
|
|
301
|
-
## `tm help [COMMAND]`
|
|
302
|
-
|
|
303
|
-
Display help for tm.
|
|
304
|
-
|
|
305
|
-
```
|
|
306
|
-
USAGE
|
|
307
|
-
$ tm help [COMMAND...] [-n]
|
|
308
|
-
|
|
309
|
-
ARGUMENTS
|
|
310
|
-
[COMMAND...] Command to show help for.
|
|
311
|
-
|
|
312
|
-
FLAGS
|
|
313
|
-
-n, --nested-commands Include all nested commands in the output.
|
|
314
|
-
|
|
315
|
-
DESCRIPTION
|
|
316
|
-
Display help for tm.
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.37/src/commands/help.ts)_
|
|
320
|
-
|
|
321
|
-
## `tm version`
|
|
322
|
-
|
|
323
|
-
```
|
|
324
|
-
USAGE
|
|
325
|
-
$ tm version [--json] [--verbose]
|
|
326
|
-
|
|
327
|
-
FLAGS
|
|
328
|
-
--verbose Show additional information about the CLI.
|
|
329
|
-
|
|
330
|
-
GLOBAL FLAGS
|
|
331
|
-
--json Format output as json.
|
|
332
|
-
|
|
333
|
-
FLAG DESCRIPTIONS
|
|
334
|
-
--verbose Show additional information about the CLI.
|
|
335
|
-
|
|
336
|
-
Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
_See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/2.2.37/src/commands/version.ts)_
|
|
340
253
|
<!-- commandsstop -->
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
## About
|
|
2
|
-
The original and most popular .NET wrapper for the [Windows Task Scheduler](https://docs.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page). It provides functionally complete classes that cover all development aspects related to system tasks.
|
|
3
|
-
|
|
4
|
-
More information can be found on the [project page on GitHub](https://github.com/dahall/taskscheduler).
|
|
5
|
-
|
|
6
|
-
## Support
|
|
7
|
-
Below are links to sites that provide in-depth examples, documentation and discussions. Please go here first with your questions as the community has been active for over a decade.
|
|
8
|
-
* [Wiki](https://github.com/dahall/TaskScheduler/wiki) - Sample code, library how-to, troubleshooting, etc.
|
|
9
|
-
* [API documentation](https://dahall.github.io/TaskScheduler) - Class/method/property documentation and examples
|
|
10
|
-
* [Full Issues Log](https://github.com/dahall/TaskScheduler/issues?q=) - Use the search box to see if your question may already be answered.
|
|
11
|
-
* [Discussion Forum](https://github.com/dahall/TaskScheduler/discussions) - Users helping users, enhancement requests, Q&A (retired Google forum [here](https://groups.google.com/forum/#!forum/taskscheduler))
|
|
12
|
-
* [Troubleshooting Tool](https://github.com/dahall/TaskSchedulerConfig) - Tool to help identify and fix configuration and connectivity issues. (ClickOnce installer [here](https://github.com/dahall/TaskSchedulerConfig/blob/master/publish/setup.exe?raw=true))
|
|
13
|
-
|
|
14
|
-
## Key Features
|
|
15
|
-
Microsoft introduced version 2.0 (internally version 1.2) with a completely new object model with Windows Vista. The managed assembly closely resembles the new object model but allows the 1.0 (internally version 1.1) COM objects to be manipulated. It will automatically choose the most recent version of the library found on the host system (up through 1.4). Core features include:
|
|
16
|
-
|
|
17
|
-
* Separate, functionally identical, libraries for .NET 2.0, 3.5, 4.0, 4.52, 5.0, 6.0, .NET Standard 2.0, .NET Core 2.0, 2.1, 3.0, 3.1.
|
|
18
|
-
* Unlike the base COM libraries, this wrapper accommodates creating and viewing tasks up and down stream.
|
|
19
|
-
* Supports all V2 native properties, even under V1 tasks.
|
|
20
|
-
* Maintain EmailAction and ShowMessageAction using PowerShell scripts for systems after Win8 where these actions have been deprecated.
|
|
21
|
-
* Supports all action types (not just ExecAction) on V1 systems (XP/WS2003) and earlier (if PowerShell is installed).
|
|
22
|
-
* Supports multiple actions on V1 systems (XP/WS2003). Native library only supports a single action.
|
|
23
|
-
* Supports serialization to XML for both 1.0 and 2.0 tasks (base library only supports 2.0)
|
|
24
|
-
* Supports task validation for targeted version.
|
|
25
|
-
* Supports secure task reading and maintenance.
|
|
26
|
-
* Fluent methods for task creation.
|
|
27
|
-
* Cron syntax for trigger creation.
|
|
28
|
-
|
|
29
|
-
The currently supported localizations include: English, Spanish, Italian, French, Chinese (Simplified), German, Polish and Russian.
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
32
|
-
You can perform several actions in a single line of code:
|
|
33
|
-
```C#
|
|
34
|
-
// Run a program every day on the local machine
|
|
35
|
-
TaskService.Instance.AddTask("Test", QuickTriggerType.Daily, "myprogram.exe", "-a arg");
|
|
36
|
-
|
|
37
|
-
// Run a custom COM handler on the last day of every month
|
|
38
|
-
TaskService.Instance.AddTask("Test", new MonthlyTrigger { RunOnLastDayOfMonth = true },
|
|
39
|
-
new ComHandlerAction(new Guid("{CE7D4428-8A77-4c5d-8A13-5CAB5D1EC734}")));
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
For many more options, use the library classes to build a complex task. Below is a brief example of how to use the library from C#.
|
|
43
|
-
```C#
|
|
44
|
-
using System;
|
|
45
|
-
using Microsoft.Win32.TaskScheduler;
|
|
46
|
-
|
|
47
|
-
class Program
|
|
48
|
-
{
|
|
49
|
-
static void Main()
|
|
50
|
-
{
|
|
51
|
-
// Get the service on the remote machine
|
|
52
|
-
using (TaskService ts = new TaskService(@"\\RemoteServer", "username", "domain", "password"))
|
|
53
|
-
{
|
|
54
|
-
// Create a new task definition and assign properties
|
|
55
|
-
TaskDefinition td = ts.NewTask();
|
|
56
|
-
td.RegistrationInfo.Description = "Does something";
|
|
57
|
-
|
|
58
|
-
// Create a trigger that will fire the task at this time every other day
|
|
59
|
-
td.Triggers.Add(new DailyTrigger { DaysInterval = 2 });
|
|
60
|
-
|
|
61
|
-
// Create an action that will launch Notepad whenever the trigger fires
|
|
62
|
-
td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null));
|
|
63
|
-
|
|
64
|
-
// Register the task in the root folder.
|
|
65
|
-
// (Use the username here to ensure remote registration works.)
|
|
66
|
-
ts.RootFolder.RegisterTaskDefinition(@"Test", td, TaskCreation.CreateOrUpdate, "username");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
1
|
+
## About
|
|
2
|
+
The original and most popular .NET wrapper for the [Windows Task Scheduler](https://docs.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page). It provides functionally complete classes that cover all development aspects related to system tasks.
|
|
3
|
+
|
|
4
|
+
More information can be found on the [project page on GitHub](https://github.com/dahall/taskscheduler).
|
|
5
|
+
|
|
6
|
+
## Support
|
|
7
|
+
Below are links to sites that provide in-depth examples, documentation and discussions. Please go here first with your questions as the community has been active for over a decade.
|
|
8
|
+
* [Wiki](https://github.com/dahall/TaskScheduler/wiki) - Sample code, library how-to, troubleshooting, etc.
|
|
9
|
+
* [API documentation](https://dahall.github.io/TaskScheduler) - Class/method/property documentation and examples
|
|
10
|
+
* [Full Issues Log](https://github.com/dahall/TaskScheduler/issues?q=) - Use the search box to see if your question may already be answered.
|
|
11
|
+
* [Discussion Forum](https://github.com/dahall/TaskScheduler/discussions) - Users helping users, enhancement requests, Q&A (retired Google forum [here](https://groups.google.com/forum/#!forum/taskscheduler))
|
|
12
|
+
* [Troubleshooting Tool](https://github.com/dahall/TaskSchedulerConfig) - Tool to help identify and fix configuration and connectivity issues. (ClickOnce installer [here](https://github.com/dahall/TaskSchedulerConfig/blob/master/publish/setup.exe?raw=true))
|
|
13
|
+
|
|
14
|
+
## Key Features
|
|
15
|
+
Microsoft introduced version 2.0 (internally version 1.2) with a completely new object model with Windows Vista. The managed assembly closely resembles the new object model but allows the 1.0 (internally version 1.1) COM objects to be manipulated. It will automatically choose the most recent version of the library found on the host system (up through 1.4). Core features include:
|
|
16
|
+
|
|
17
|
+
* Separate, functionally identical, libraries for .NET 2.0, 3.5, 4.0, 4.52, 5.0, 6.0, .NET Standard 2.0, .NET Core 2.0, 2.1, 3.0, 3.1.
|
|
18
|
+
* Unlike the base COM libraries, this wrapper accommodates creating and viewing tasks up and down stream.
|
|
19
|
+
* Supports all V2 native properties, even under V1 tasks.
|
|
20
|
+
* Maintain EmailAction and ShowMessageAction using PowerShell scripts for systems after Win8 where these actions have been deprecated.
|
|
21
|
+
* Supports all action types (not just ExecAction) on V1 systems (XP/WS2003) and earlier (if PowerShell is installed).
|
|
22
|
+
* Supports multiple actions on V1 systems (XP/WS2003). Native library only supports a single action.
|
|
23
|
+
* Supports serialization to XML for both 1.0 and 2.0 tasks (base library only supports 2.0)
|
|
24
|
+
* Supports task validation for targeted version.
|
|
25
|
+
* Supports secure task reading and maintenance.
|
|
26
|
+
* Fluent methods for task creation.
|
|
27
|
+
* Cron syntax for trigger creation.
|
|
28
|
+
|
|
29
|
+
The currently supported localizations include: English, Spanish, Italian, French, Chinese (Simplified), German, Polish and Russian.
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
You can perform several actions in a single line of code:
|
|
33
|
+
```C#
|
|
34
|
+
// Run a program every day on the local machine
|
|
35
|
+
TaskService.Instance.AddTask("Test", QuickTriggerType.Daily, "myprogram.exe", "-a arg");
|
|
36
|
+
|
|
37
|
+
// Run a custom COM handler on the last day of every month
|
|
38
|
+
TaskService.Instance.AddTask("Test", new MonthlyTrigger { RunOnLastDayOfMonth = true },
|
|
39
|
+
new ComHandlerAction(new Guid("{CE7D4428-8A77-4c5d-8A13-5CAB5D1EC734}")));
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For many more options, use the library classes to build a complex task. Below is a brief example of how to use the library from C#.
|
|
43
|
+
```C#
|
|
44
|
+
using System;
|
|
45
|
+
using Microsoft.Win32.TaskScheduler;
|
|
46
|
+
|
|
47
|
+
class Program
|
|
48
|
+
{
|
|
49
|
+
static void Main()
|
|
50
|
+
{
|
|
51
|
+
// Get the service on the remote machine
|
|
52
|
+
using (TaskService ts = new TaskService(@"\\RemoteServer", "username", "domain", "password"))
|
|
53
|
+
{
|
|
54
|
+
// Create a new task definition and assign properties
|
|
55
|
+
TaskDefinition td = ts.NewTask();
|
|
56
|
+
td.RegistrationInfo.Description = "Does something";
|
|
57
|
+
|
|
58
|
+
// Create a trigger that will fire the task at this time every other day
|
|
59
|
+
td.Triggers.Add(new DailyTrigger { DaysInterval = 2 });
|
|
60
|
+
|
|
61
|
+
// Create an action that will launch Notepad whenever the trigger fires
|
|
62
|
+
td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null));
|
|
63
|
+
|
|
64
|
+
// Register the task in the root folder.
|
|
65
|
+
// (Use the username here to ensure remote registration works.)
|
|
66
|
+
ts.RootFolder.RegisterTaskDefinition(@"Test", td, TaskCreation.CreateOrUpdate, "username");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
72
|
For extended examples on how to the use the library, look at the [Examples Page](https://github.com/dahall/TaskScheduler/wiki/Examples).
|