Invoke Power Shell: Access is denied. To run this cmdlet, start Windows PowerShell with the “Run as administrator” option.
Supported by this thread, I was able to make a simple process:
However, running this will prompt the UAC (which would need to be disabled for this to work, which is highly not recommanded).
Actually, there is a solution to it (credit to out of our awesome uipathers). See his explanation below:
I use the activity invoking a script. If the script tries to invoke:
Start-Process notepad.exe -Verb runAs
then the UAC dialog will appear defeating the purpose.
If the script instead says:
$credential = New-Object System.Management.Automation.PsCredential(“admin”, (ConvertTo-SecureString “Passw0rd1” -AsPlainText -Force))
Start-Process notepad.exe -Credential $credential
then all is well and the process is run as an administrator without a UAC dialog coming up.
This method requires a prior relaxation of the ability to execute scripts using “Set-ExecutionPolicy”.
Link to .xaml and ps1 script here:
run_as_admin.zip (1.7 KB)
Hi @loginerror ,
can you please help with the packages that you have used in that particular process? Ive been trying t use this xaml, but it shows invalid activity
I tried running your process. It throws me this error.
You’re right, you need to make sure the path of the invoke activity is in the correct folder. By default the zip didn’t contain that folder, whoops
This change should fix it: