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 :: zsh list environment variables 
Shell :: check if service is running server 
Shell :: how to install sshpass on mac 
Shell :: how to uninstall git 
Shell :: git push reset 
Shell :: centos copy folder 
Shell :: angular bootstrap 
Shell :: running shell commands nodejs 
Shell :: Installed Build Tools revision 32.0.0 is corrupted. Remove and install again using the SDK Manager 
Shell :: convert cer to crt linux mint 
Shell :: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 
Shell :: run mutiple sass files at once 
Shell :: pod upgrade 
Shell :: ghost in the shell 
Shell :: linux back cd 
Shell :: git diff files of different branches 
Shell :: add user to debian 11 
Shell :: ubuntu add public key to server 
Shell :: 10250: connect: no route to host kubernetes 
Shell :: docker redis 
Shell :: phpcs other xml file other location phpcs standard xml 
Shell :: code to change the mac address kali linux 
Shell :: how to WSL2 
Shell :: how to get github url 
Shell :: wallpaper engine linux 
Shell :: linux while loop 
Shell :: bash data types 
Shell :: stop apache2 
Shell :: how to add a directory to path in linux 
Shell :: create user linux 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =