我正在尝试使用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
任何想法为什么它不会运行脚本,即使我以管理员身份运行脚本?还有什么我需要改变的吗?
1 回答
-Verb
参数仅需要 one 参数,例如print
. 在提升的情况下,它将是RunAs
,它将使用当前用户的完全权限运行该进程 .来自Start-Process documentation:
指定启动进程时要使用的动词 . 可用的动词由在该过程中运行的文件的文件扩展名确定 .
下表显示了一些常见进程文件类型的动词 .
若要查找可与进程中运行的文件一起使用的谓词,请使用
New-Object
cmdlet为该文件创建System.Diagnostics.ProcessStartInfo
对象 . 可用的动词位于ProcessStartInfo
对象的Verbs属性中 .