From c535f038a9be015528f1a24d32caaf19ca5f1c6c Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 9 Aug 2022 19:47:51 +0200 Subject: [PATCH] feat: enable using chocolatey --- handlers/chocolatey/install | 2 ++ packages/chocolatey/powershell.ps1 | 15 ++++----------- packages/chocolateygui/chocolatey | 0 3 files changed, 6 insertions(+), 11 deletions(-) create mode 100644 handlers/chocolatey/install create mode 100644 packages/chocolateygui/chocolatey diff --git a/handlers/chocolatey/install b/handlers/chocolatey/install new file mode 100644 index 0000000..e8690c6 --- /dev/null +++ b/handlers/chocolatey/install @@ -0,0 +1,2 @@ +#!/bin/sh +powershell -Command "Start-Process 'choco' -Verb runAs -ArgumentList 'install $*'" \ No newline at end of file diff --git a/packages/chocolatey/powershell.ps1 b/packages/chocolatey/powershell.ps1 index db353c2..6fc1a68 100755 --- a/packages/chocolatey/powershell.ps1 +++ b/packages/chocolatey/powershell.ps1 @@ -2,17 +2,14 @@ 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 = @( + $Arguments = @( '-NoProfile', '-ExecutionPolicy Bypass', '-NoExit', @@ -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 diff --git a/packages/chocolateygui/chocolatey b/packages/chocolateygui/chocolatey new file mode 100644 index 0000000..e69de29