[英]How to setup a Powershell Script in Windows Task Scheduler with admin permissions?
[英]How to update a Windows Task Scheduler task from an updater/script running as admin
我正在为我的应用程序编写更新程序,并希望更改由以下配置的“Windows 任务计划程序”任务:
schtasks /create /sc once /tn my_task /tr MyApp.exe /rl highest /st 00:00
更新程序以“最高权限”运行,我主要想更改MyApp.exe
的路径。
我试过了:
schtasks /Change /tn my_task /tr MyUpdatedApp.exe
(但它会问: Please enter the run as password for...
即使脚本已经以管理员身份运行。因此对用户不友好,甚至无法在我的脚本更新中工作。)Get-/Set-ScheduledJob
powershell 脚本(但它说: A scheduled job definition with Name my_task could not be found
。帮助文本甚至指出Although jobs that are created by using the Register-ScheduledJob cmdlet appear in Task Scheduler, Get-ScheduledJob gets only scheduled jobs. It does not get scheduled tasks created in Task Scheduler.
)如何在没有用户交互的情况下从我的更新程序/脚本更新我的计划任务?
我已经使用带有以下命令的 XML 文件导出和重新创建任务:
schtasks /create /f /tn my_task /xml C:\somewhere\my_task.xml
我通过在 GUI 中手动导出文件并将其存储为我的应用程序的一部分来创建my_task.xml
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.