locked
Disable UAC prompt for Powershell Script RRS feed

  • Question

  • I wrote a PowerShell script which self elevates it to "Run as Administrator",

    The script is called from a node.js file and the beginning code for pwr.ps1 is as follows: 

    if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
     { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit}

    // my remaining code.

    but I am still getting a UAC prompt for Yes or No.
    I have the admin privileges , Is there any scripting solution or a Command so that I can silent the UAC prompt.
    I don't want to disable UAC from control panel or install Third party applications.

    Thursday, July 6, 2017 6:41 AM

All replies