From 8d5e4ec0d4cccdb1daebea0bcb771ebe3b8ae05a Mon Sep 17 00:00:00 2001 From: ilih Date: Tue, 4 Feb 2025 02:11:12 +0000 Subject: [PATCH] PowerShell commands are not always executed in the current directory. "Set-Location -LiteralPath '%CD%'; " added to ensure the current directory. "-LiteralPath" is used to prevent problems if the path contains special characters (for the PowerShell) like square brackets [] Without those changes, PowerShell tries to download a repo.zip to the system folder and it results in an error "access to the path is denied". --- patch.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patch.bat b/patch.bat index eba8a67..2161ea4 100644 --- a/patch.bat +++ b/patch.bat @@ -80,7 +80,7 @@ exit /b :download_extract REM Download zip file echo "Downloading latest patch..." -!_my_shell! -Command "Invoke-WebRequest -Uri 'https://gitgud.io/%username%/%repo%/-/archive/%branch%/%repo%-%branch%.zip' -OutFile 'repo.zip'" +!_my_shell! -Command "Set-Location -LiteralPath '%CD%'; Invoke-WebRequest -Uri 'https://gitgud.io/%username%/%repo%/-/archive/%branch%/%repo%-%branch%.zip' -OutFile 'repo.zip'" if !errorlevel! neq 0 ( pause exit /b @@ -88,7 +88,7 @@ if !errorlevel! neq 0 ( REM Extract contents, overwriting conflicts echo "Extracting..." -!_my_shell! -Command "Expand-Archive -Path '.\repo.zip' -DestinationPath '.' -Force" +!_my_shell! -Command "Set-Location -LiteralPath '%CD%'; Expand-Archive -Path '.\repo.zip' -DestinationPath '.' -Force" echo "Applying patch..." xcopy /s /e /y "%repo%-%branch%\*" "."