2
votes

I'm trying to modify the permissions of the UAC with a powershell script that looks like:

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

Even though I am running the script as administrator, I still get the following error:

Set-ItemProperty : Requested registry access is not allowed. At 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

Any ideas why it wont run the script even though I am running the script as administrator? Is there something else I need to change?

1
I think you want just -Verb runAs -- no AdministratorAndy Arismendi
If you want to make that an answer, I'll give you the points.Thomas

1 Answers

2
votes

The -Verb parameter only takes one argument e.g. print. In the case of elevation it will be RunAs which will run the process with the current user's full privileges.


From the Start-Process documentation:

-Verb <String>

Specifies a verb to use when starting the process. The verbs that are available are determined by the file name extension of the file that runs in the process.

The following table shows the verbs for some common process file types.

File type  Verbs
---------  -------
.cmd       Edit, Open, Print, Runas
.exe       Open, RunAs
.txt       Open, Print, PrintTo
.wav       Open, Play

To find the verbs that can be used with the file that runs in a process, use the New-Object cmdlet to create a System.Diagnostics.ProcessStartInfo object for the file. The available verbs are in the Verbs property of the ProcessStartInfo object.