views:

15

answers:

1

I want to script creating a scheduled task with VBScript.

I need to use the Enumerated Types of the Task Scheduler object to set the task to run with "Highest Privileges".

Anyone know how I set this?

Thanks,

Ben

+1  A: 

I guess you're using the Task Scheduler 2.0 Scripting API, right?

The easiest solution is to manually define any constants needed in your script:

Const TASK_RUNLEVEL_LUA     = 0
Const TASK_RUNLEVEL_HIGHEST = 1


Alternatively, you can try the following: wrap your VBScript code in a Windows Script (.wsf) file and use the <reference> tag to import the Task Scheduler type library, so that your script has access to constants defined in that type library. Your .wsf script would look something like this:

<job>
  <reference object="Schedule.Service" />
  <script language="VBScript">
    WScript.Echo TASK_RUNLEVEL_HIGHEST
  </script>
</job>

You can find more info on Windows script files here: Using Windows Script Files (.wsf).

Helen