![Cómo seleccionar usando un script en el Programador de tareas "ejecutar con los privilegios más altos"](https://rvso.com/image/769282/C%C3%B3mo%20seleccionar%20usando%20un%20script%20en%20el%20Programador%20de%20tareas%20%22ejecutar%20con%20los%20privilegios%20m%C3%A1s%20altos%22.png)
Hola, estoy creando algunas secuencias de comandos para agregar una tarea en un Programador de tareas. Sin embargo, necesito tener una secuencia de comandos para seleccionar "ejecutar con los privilegios más altos".
Código de muestra:
Dim settings
Set settings = taskDefinition.Settings
settings.Enabled = True
settings.StartWhenAvailable = True
settings.Hidden = False
Respuesta1
Puede lograr esto con la -RunLevel Highest
bandera for New-ScheduledTaskPrincipal
en PowerShell.
Ejemplo:
# 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