diff --git a/Install-media-tools.ps1 b/Install-media-tools.ps1 index 1e51f4f..7416783 100644 --- a/Install-media-tools.ps1 +++ b/Install-media-tools.ps1 @@ -1,1452 +1,212 @@ +# Install-media-tools.ps1 +# Run in elevated PowerShell: +# Inside the VM: +# Open Start +# Type PowerShell +# Right-click Windows PowerShell → Run as administrator +# chdir to the location of this script +# powershell -ExecutionPolicy Bypass -File .\Install-media-tools.ps1 - - +$ErrorActionPreference = "Stop" +# Where to install (bin folder on PATH) +$BinDir = "C:\Tools\bin" +$ToolsRoot = "C:\Tools" +$SubtitleEditDir = Join-Path $ToolsRoot "SubtitleEdit" +$WorkDir = Join-Path $env:TEMP ("media-tools-" + [guid]::NewGuid().ToString("N")) +New-Item -ItemType Directory -Force -Path $BinDir | Out-Null +New-Item -ItemType Directory -Force -Path $WorkDir | Out-Null +New-Item -ItemType Directory -Force -Path $SubtitleEditDir | Out-Null +function Download-File([string]$Url, [string]$OutFile) { + Write-Host "Downloading: $Url" + Invoke-WebRequest -Uri $Url -OutFile $OutFile -UseBasicParsing +} -
- - - - - - - +function Add-ToMachinePath([string]$PathToAdd) { + $current = [Environment]::GetEnvironmentVariable("Path", "Machine") + if (-not $current) { $current = "" } - + # Compare case-insensitively on Windows + $parts = $current.Split(";", [System.StringSplitOptions]::RemoveEmptyEntries) + $exists = $parts | Where-Object { $_.TrimEnd("\") -ieq $PathToAdd.TrimEnd("\") } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -