首页 文章

修改UAC时拒绝Powershell管理员权限

提问于
浏览
1

我正在尝试使用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 回答

  • 2

    -Verb 参数仅需要 one 参数,例如 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 对象的Verbs属性中 .

相关问题