From 5468b8689816dc143f857f1c6e3ff77b4b426941 Mon Sep 17 00:00:00 2001 From: MyDrift Date: Fri, 23 Aug 2024 12:49:51 +0200 Subject: [PATCH] last fix --- scripts/start.ps1 | 18 +++--------------- windev.ps1 | 15 +++------------ 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/scripts/start.ps1 b/scripts/start.ps1 index 1cb32415..06e53b69 100644 --- a/scripts/start.ps1 +++ b/scripts/start.ps1 @@ -47,22 +47,10 @@ $sync.ProcessRunning = $false if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Output "Winutil needs to be run as Administrator. Attempting to relaunch." - $script = if (Test-Path "$PSScriptRoot\winutil.ps1") { - "$PSScriptRoot\winutil.ps1" - } else { - "irm christitus.com/win | iex" - } - $powershellcmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) { - "pwsh.exe" - } else { - "powershell.exe" - } + $script = if ($MyInvocation.MyCommand.Path) { "& '" + $MyInvocation.MyCommand.Path + "'" } else { "irm 'https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1' | iex"} + $powershellcmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) { "pwsh" } else { "powershell" } + $processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) { "wt.exe" } else { $powershellcmd } - $processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) { - "wt.exe" - } else { - $powershellcmd - } Start-Process $processCmd -ArgumentList "$powershellcmd -ExecutionPolicy Bypass -NoProfile -Command $script" -Verb RunAs break diff --git a/windev.ps1 b/windev.ps1 index a9af524b..6a993380 100644 --- a/windev.ps1 +++ b/windev.ps1 @@ -15,19 +15,10 @@ if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Output "Winutil needs to be run as Administrator. Attempting to relaunch." - $script = "irm christitus.com/windev | iex" + $script = if (!$MyInvocation.MyCommand.Path) { "& '" + $MyInvocation.MyCommand.Path + "'" } else { "irm 'https://github.com/ChrisTitusTech/winutil/raw/main/windev.ps1' | iex"} + $powershellcmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) { "pwsh" } else { "powershell" } + $processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) { "wt.exe" } else { $powershellcmd } - $powershellcmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) { - "pwsh.exe" - } else { - "powershell.exe" - } - - $processCmd = if (Get-Command wt.exe -ErrorAction SilentlyContinue) { - "wt.exe" - } else { - $powershellcmd - } Start-Process $processCmd -ArgumentList "$powershellcmd -ExecutionPolicy Bypass -NoProfile -Command $script" -Verb RunAs break