@echo off rem =========================================================================== rem GPU Mem Tool - launcher (requests administrator privileges automatically) rem GPU 显存释放工具 - 启动器(自动请求管理员权限) rem rem Double-click this file. Click "Yes" on the UAC prompt. rem 双击本文件即可;弹出 UAC 提权窗口时点「是」。 rem rem Keep this file ASCII-only so it works under any console codepage. rem The script path is quoted via [char]34 so paths containing spaces work. rem =========================================================================== setlocal title GPU Mem Tool Launcher set "PS1=%~dp0GpuMemTool.ps1" if not exist "%PS1%" ( echo [ERROR] GpuMemTool.ps1 not found next to this launcher: echo %~dp0 echo. pause exit /b 1 ) powershell.exe -NoProfile -ExecutionPolicy Bypass -Command ^ "$ps1 = '%PS1%';" ^ "$q = [char]34;" ^ "$argline = '-NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File ' + $q + $ps1 + $q;" ^ "$me = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent();" ^ "if ($me.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {" ^ " Start-Process -FilePath 'powershell.exe' -ArgumentList $argline" ^ "} else {" ^ " try { Start-Process -FilePath 'powershell.exe' -ArgumentList $argline -Verb RunAs -ErrorAction Stop }" ^ " catch { Write-Host ''; Write-Host '[!] Elevation cancelled or failed:' $_.Exception.Message -ForegroundColor Yellow; Start-Sleep -Seconds 3 }" ^ "}" exit /b 0