Skip to content

Instantly share code, notes, and snippets.

@Niktendo
Last active September 24, 2022 15:39
Show Gist options
  • Select an option

  • Save Niktendo/e9fb462989bd819ee2a5a80283045784 to your computer and use it in GitHub Desktop.

Select an option

Save Niktendo/e9fb462989bd819ee2a5a80283045784 to your computer and use it in GitHub Desktop.
Win7+-Scripts
$netshare = "H:\Neuer Ordner"
$host.UI.RawUI.WindowTitle = "Herunterladen der Abhaengigkeiten..."
$params="%*"
function Expand-ZIPFile($file, $destination)
{
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}
Remove-Item "$netshare\pwsh" -Recurse -force -ErrorAction Continue
(New-Object System.Net.WebClient).DownloadFile('https://github.com/PowerShell/PowerShell/releases/download/v7.3.0-preview.8/PowerShell-7.3.0-preview.8-win-x64.zip',"$env:temp\pwsh.zip")
Expand-ZipFile "$env:temp\pwsh.zip" -destination "$netshare\pwsh"
Remove-Item "$env:temp\pwsh.zip"
$value = "$netshare\pwsh"
$path = [System.Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::User)
$new = ($path.Split(';') | Where-Object { $_ -ne "$value" }) -join ';'
[System.Environment]::SetEnvironmentVariable("PATH", $new, [EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("PATH", $new + ";$value", [EnvironmentVariableTarget]::User)
@echo off
echo %1
powershell -ExecutionPolicy Bypass -File %1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment