Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

run powershell command as administrator

powershell Start-Process powershell -Verb runAs
Comment

run application as administrator with powershell

PS> Start-Process powershell -Verb runAs
Comment

powershell script as administrator

param([switch]$Elevated)

function Test-Admin {
    $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
    $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

if ((Test-Admin) -eq $false)  {
    if ($elevated) {
        # tried to elevate, did not work, aborting
    } else {
        Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
    }
    exit
}

'running with full privileges'
Comment

PREVIOUS NEXT
Code Example
Shell :: npm install moment 
Shell :: php curl ignore ssl certificate 
Shell :: git push to all remotes 
Shell :: install readline-sync 
Shell :: docker Problem with the CMake installation, aborting build. CMake executable is cmake 
Shell :: nohup set output file 
Shell :: mac install pytorch 
Shell :: airflow username password 
Shell :: git ubuntu store credential 
Shell :: pip install docusign_esign 
Shell :: choco list local packages 
Shell :: install kivy pip 
Shell :: see installed packages pacman 
Shell :: address already in use 0.0.0.0:8080 
Shell :: dash bootstrap install 
Shell :: flutter create new project 
Shell :: tail colorful 
Shell :: unable to locate package build-essential 
Shell :: ionic 4 install bootstrap 
Shell :: node_modules not being ignored git 
Shell :: input bash 
Shell :: cron logs 
Shell :: convert pem to private key openssl 
Shell :: notebook 
Shell :: composer drupal install 
Shell :: speed test centos 
Shell :: ubuntu last logs 
Shell :: homebrew linux 
Shell :: cannot open display: :0 wsl 
Shell :: git fetch prune tags 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =