feat: enable using chocolatey

This commit is contained in:
xeruf 2022-08-09 19:47:51 +02:00
parent 2626baa858
commit c535f038a9
3 changed files with 6 additions and 11 deletions

View File

@ -0,0 +1,2 @@
#!/bin/sh
powershell -Command "Start-Process 'choco' -Verb runAs -ArgumentList 'install $*'"

View File

@ -2,15 +2,12 @@ Param(
[string]$Loc
)
$Delay = 2
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
[Security.Principal.WindowsBuiltInRole] 'Administrator')
)
{
Write-Host "Not elevated, restarting in $Delay seconds ..."
Write-Host "Not elevated, restarting..."
$Loc = Get-Location
Start-Sleep -Seconds $Delay
$Arguments = @(
'-NoProfile',
@ -23,13 +20,8 @@ if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]:
Start-Process -FilePath PowerShell.exe -Verb RunAs -ArgumentList $Arguments
Break
}
else
{
Write-Host "Already elevated, exiting in $Delay seconds..."
Start-Sleep -Seconds $Delay
}
if($Loc.Length -gt 1){
Set-Location $Loc.Substring(1,$Loc.Length-1)
Set-Location $Loc.Substring(1,$Loc.Length-2)
}
# https://github.com/lukegackle/PowerShell-Self-Elevate-Keeping-Current-Directory/blob/master/Self%20Elevate%20Keeping%20Directory.ps1
@ -139,4 +131,5 @@ if (!(Test-Path $ChocoInstallPath)) {
# TODO If offline:
#Install-ChocolateyFromPackage 'chocolatey.0.11.2.nupkg'
}
choco feature enable -n allowGlobalConfirmation
choco upgrade all

View File