我正在尝试使用看起来像这样的PowerShell脚本来修改UAC的权限:
Start-Process powershell -Verb runAs Administrator
Set-ItemProperty -Path registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA -Value 0
$UAC = Get-ItemProperty -Path registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA
$UAC.EnableLUA
即使我以管理员身份运行脚本,我仍然会收到以下错误:
Set-ItemProperty:不允许请求的注册表访问。在 C:\ Users \ Bert \ Desktop \ autoLims.ps1:8 char:17 + Set-ItemProperty<<<< -Path registry :: HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows \ CurrentVersion \ policies \ system -Name EnableLUA -Value 0 + CategoryInfo:PermissionDenied:(HKEY_LOCAL_MACH ... policies \ system:String)[Set-ItemProperty], 抛出:SecurityException + FullyQualifiedErrorId:System.Security.SecurityException,Microsoft.PowerShell.Commands.SetItemPropertyCommand
即使我以管理员身份运行脚本,为什么它不会运行脚本的任何想法?还有什么我需要改变的吗?
答案 0 :(得分:2)
-Verb
参数只需一个参数,例如print
。在提升的情况下,它将是RunAs
,它将以当前用户的完全权限运行该进程。
来自Start-Process documentation:
-Verb <String>
指定启动进程时要使用的谓词。可用的动词由在该过程中运行的文件的文件扩展名确定。
下表显示了一些常见过程文件类型的动词。
File type Verbs
--------- -------
.cmd Edit, Open, Print, Runas
.exe Open, RunAs
.txt Open, Print, PrintTo
.wav Open, Play
要查找可与进程中运行的文件一起使用的谓词,请使用New-Object
cmdlet为该文件创建System.Diagnostics.ProcessStartInfo
对象。可用的动词位于ProcessStartInfo
对象的动词属性中。