I am trying to create a batch script that will download a file based on the computers OS and Architecture. My only problem is whenever I run the batch file, it closes after checking what archeticture the computer is using. I feel like its the if statements inside another if statement but I'm not sure. (Also, I know it specifically says not to have a vague title, but I wasnt sure what a better one would be.)
My intent is to have a portable program that runs an exe file, and runs this when the file is missing. I've tried different ways to check for the OS, and have tried rearranging the if statements, but nothing's worked so far.
setlocal
for /f "tokens=4-5 delims=. " %%i in ('ver') do set WINOS=%%i.%%j
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /I "x86" > NUL && set ARCHCHECK=32BIT || set ARCHCHECK=64BIT
if %WINOS%==10.0 (
if %ARCHCHECK%==32BIT (
echo You are running Windows 10 on a 32 Bit architecture. Getting right files.
powershell -Command "IInvoke-WebRequest https://example.com/example.zip -OutFile example.zip"
if %ARCHCHECK%==64BIT (
echo You are running Windows 10 on a 64 Bit architecture. Getting right files.
powershell -Command "Invoke-WebRequest https://example.com/example.zip -OutFile example.zip"
if %WINOS%==6.1 (
if %ARCHCHECK%==32BIT (
echo You are running Windows 7 on a 32 Bit architecture. Getting right files.
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://example.com/example.zip', 'example.zip')"
if %ARCHCHECK%==64BIT (
echo You are running Windows 7 on a 64 Bit architecture. Getting right files.
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://example.com/example.zip', 'example.zip')"
And so on for Windows 8
I am expecting for the batch script to find the OS (To know which powershell command to use) then the architecture (To know what version to download) then run the download command. What actually happens is the script will run all the way up to the registry query, and then before it starts working on the if statements, it stops and closes the window.