こんにちは。タスク スケジューラにタスクを追加するためにスクリプトを作成しています。ただし、「最高権限で実行」を選択するためのスクリプトが必要です。
サンプルコード:
Dim settings
Set settings = taskDefinition.Settings
settings.Enabled = True
settings.StartWhenAvailable = True
settings.Hidden = False
答え1
-RunLevel Highest
PowerShellのフラグを使用してこれを実現できますNew-ScheduledTaskPrincipal
。
例:
# Set the scheduled task time and repitition
$TaskTime = New-ScheduledTaskTrigger -Daily -At 12:00
# Set the task to run as a local administrator with highest level privileges
$TaskUser = New-ScheduledTaskPrincipal -GroupId "BUILTIN\Administrators" -RunLevel Highest
# Set actions the schedule task should perform
$Action1 = New-ScheduledTaskAction -Execute "chrome.exe"
$Action2 = New-ScheduledTaskAction -Execute "notepad.exe"
# Registers the task with Task Scheduler
Register-ScheduledTask "Test Scheduled Task" -Action $Action1,$Action2 -Principal $TaskUser