2012-03-05 23 views
10

¿Cómo desactivo el UAC usando un script de PowerShell? Puedo hacer esto manualmente a través del registro con el de añadir la siguiente entrada de registro¿Cómo desactivo el UAC con Windows PowerShell?

Key: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA 
Value: 0 
Type: DWORD 

El guión debe tener en cuenta la posibilidad de que esta clave ya está presente y establecido de forma incorrecta.

Respuesta

1

1 - Añadir las dos funciones siguientes a su perfil de PowerShell (C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1)

2 - Ejecutar Disable-UAC en PowerShell

3 - Reinicio para que los cambios surtan efecto. El uso de PowerShell, esto sería Restart-Computer -Force -Confirm:$false

Function Test-RegistryValue 
{ 
    param(
     [Alias("RegistryPath")] 
     [Parameter(Position = 0)] 
     [String]$Path 
     , 
     [Alias("KeyName")] 
     [Parameter(Position = 1)] 
     [String]$Name 
    ) 

    process 
    { 
     if (Test-Path $Path) 
     { 
      $Key = Get-Item -LiteralPath $Path 
      if ($Key.GetValue($Name, $null) -ne $null) 
      { 
       if ($PassThru) 
       { 
        Get-ItemProperty $Path $Name 
       }  
       else 
       { 
        $true 
       } 
      } 
      else 
      { 
       $false 
      } 
     } 
     else 
     { 
      $false 
     } 
    } 
} 

Function Disable-UAC 
{ 
    $EnableUACRegistryPath = "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" 
    $EnableUACRegistryKeyName = "EnableLUA" 
    $UACKeyExists = Test-RegistryValue -RegistryPath $EnableUACRegistryPath -KeyName $EnableUACRegistryKeyName 
    if ($UACKeyExists) 
    { 
     Set-ItemProperty -Path $EnableUACRegistryPath -Name $EnableUACRegistryKeyName -Value 0 
    } 
    else 
    { 
     New-ItemProperty -Path $EnableUACRegistryPath -Name $EnableUACRegistryKeyName -Value 0 -PropertyType "DWord" 
    } 
} 
18
New-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA -PropertyType DWord -Value 0 -Force 
Restart-Computer 
+0

¿El reinicio tiene que suceder para que el cambio tenga lugar? –

+0

Nevermind acaba de responder mi propia pregunta. –

+0

Probé este comportamiento con éxito en Windows 10, ¿también funciona en Windows 7? Desafortunadamente no he ganado 7 clientes para la prueba propia. Saludos, Alejandro –

Cuestiones relacionadas