This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
/
run.ps1
32 lines (27 loc) · 1.53 KB
/
run.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Self-elevate the script if required
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
if (-not $myWindowsPrincipal.IsInRole($adminRole))
{
# We are not running "as Administrator" - so relaunch as administrator
# Create a new process object that starts PowerShell
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
# Specify the current script path and name as a parameter
$newProcess.Arguments = $myInvocation.MyCommand.Definition;
# Indicate that the process should be elevated
$newProcess.Verb = "runas";
# Start the new process
[System.Diagnostics.Process]::Start($newProcess) | Out-Null
# Exit from the current, unelevated, process
exit
}
$documents = $env:USERPROFILE + "\\Documents"
Write-Output "Downloading WindowsToolbox..."
Invoke-WebRequest -Uri "https://github.com/WinTweakers/WindowsToolbox/archive/refs/heads/main.zip" -OutFile $documents\WindowsToolbox.zip
Write-Output "Extracting WindowsToolbox..."
Expand-Archive -LiteralPath $documents\WindowsToolbox.zip -DestinationPath $documents -Force
Remove-Item -Path "$documents\WindowsToolbox.zip" -Force
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
Get-ChildItem -Recurse $documents\WindowsToolbox-main\*.ps*1 | Unblock-File
Start-Process -FilePath $documents\WindowsToolbox-main\WindowsToolbox.cmd