mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45:52 -06:00
2d751f4e8c
* fixes - change fontsize back to 12 - add correct handling of windows - removed double click handling of winutil * readd double click * fixes - argument passing on elevation & to windev script - remove shell output of log * improve compile -run - added $args param for args that get passed to winutil - improved starting new Shell logic * fix: compile's run logic - removed old logic - fixed command to run in new shell - replaced $args with $arg * fix: logs & border - move log start to after admin elevation - fix color of border on fixed tweaks button. * fix: MicrowinInjectDrivers's Margin - use theme value instead of custom value * change microwin checkbox margin - set cutom microwin checkbox margin due to cut off content * fix layouting of nav bar - replace strange collumndefinition to fix bugs, make sense and look better * rename $arg to $Arguments * change maxresolution from 1380 to 1280
62 lines
2.6 KiB
PowerShell
62 lines
2.6 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
This Script is used as a target for the https://christitus.com/windev alias.
|
|
It queries the latest winget release (no matter if Pre-Release, Draft or Full Release) and invokes It
|
|
.DESCRIPTION
|
|
This Script provides a simple way to always start the bleeding edge release even if it's not yet a full release.
|
|
This function should be run with administrative privileges.
|
|
Because this way of recursively invoking scripts via Invoke-Expression it might very well happen that AV Programs flag this because it's a common way of mulitstage exploits to run
|
|
.EXAMPLE
|
|
irm https://christitus.com/windev | iex
|
|
OR
|
|
Run in Admin Powershell > ./windev.ps1
|
|
#>
|
|
|
|
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."
|
|
# Capture all the arguments passed to the script
|
|
$argList = $args -join ' '
|
|
|
|
$script = if ($MyInvocation.MyCommand.Path) {
|
|
"& { & '$($MyInvocation.MyCommand.Path)' $argList }"
|
|
} else {
|
|
"iex '& { $(irm https://github.com/ChrisTitusTech/winutil/raw/main/windev.ps1) } $argList'"
|
|
}
|
|
|
|
$powershellcmd = if (Get-Command pwsh -ErrorAction SilentlyContinue) { "pwsh" } else { "powershell" }
|
|
$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
|
|
}
|
|
|
|
# Function to fetch the latest release tag from the GitHub API
|
|
function Get-LatestRelease {
|
|
try {
|
|
$releases = Invoke-RestMethod -Uri 'https://api.github.com/repos/ChrisTitusTech/winutil/releases'
|
|
$latestRelease = $releases | Where-Object {$_.prerelease -eq $true} | Select-Object -First 1
|
|
return $latestRelease.tag_name
|
|
} catch {
|
|
Write-Host "Error fetching release data: $_" -ForegroundColor Red
|
|
return $latestRelease.tag_name
|
|
}
|
|
}
|
|
|
|
# Function to redirect to the latest pre-release version
|
|
function RedirectToLatestPreRelease {
|
|
$latestRelease = Get-LatestRelease
|
|
if ($latestRelease) {
|
|
$url = "https://github.com/ChrisTitusTech/winutil/releases/download/$latestRelease/winutil.ps1"
|
|
} else {
|
|
Write-Host 'Unable to determine latest pre-release version.' -ForegroundColor Red
|
|
Write-Host "Using latest Full Release"
|
|
$url = "https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1"
|
|
}
|
|
|
|
iex "& { $(irm $url) } $argList"
|
|
}
|
|
|
|
# Call the redirect function
|
|
RedirectToLatestPreRelease
|