我想使用管理权限运行这个powershell脚本,这样它就不会给我错误:
下面是脚本:
$processes = "PDStyleAgent", "AdobeIPCBroker", "CCXProcess", "RichVideo64", "CCLibrary", "AdobeNotificationClient", "AdobeUpdateService", "PDHanumanSvr", "PDR"
Foreach ($process in $processes){
try {
$f = Get-Process $process -ErrorAction Stop
$f | kill
Write-Output "$process killed."
}
catch [Microsoft.PowerShell.Commands.ProcessCommandException]{
Write-Output "No instances of $process running."
}
}
Start-Sleep -Seconds 3我想要运行这个脚本,这样它就可以终止产生错误的进程。
发布于 2022-02-07 15:28:06
使用管理权限运行PowerShell的一些方法:
Start-Process powershell -Verb runAsPowerShell -f C:\ScriptPath有关更多细节,您可以查看这个StackOverflow问题和答案。
发布于 2022-02-07 15:48:16
我不知道你到底在问什么。如果要以管理员身份启动脚本,则需要“以管理员身份”打开PowerShell窗口。
顺便说一句,脚本本身可以在不失去功能的情况下简化:
$processes = "PDStyleAgent", "AdobeIPCBroker", "CCXProcess", "RichVideo64", "CCLibrary", "AdobeNotificationClient", "AdobeUpdateService", "PDHanumanSvr", "PDR"
Get-Process -Name $processes -ErrorAction SilentlyContinue | Stop-Process -Verbose发布于 2022-02-07 14:25:55
1.在桌面上创建Powershell脚本的快捷方式
2.右键单击快捷方式并单击“属性”。
3.单击快捷方式选项卡
4.单击“高级”
5.选择
注意:在脚本路径前面添加powershell -f
https://stackoverflow.com/questions/71019989
复制相似问题