NaJeEb303 Posted December 19, 2013 Share Posted December 19, 2013 hello everyone,i need some help in a batch script, a very common problem, surfed the internet alot and als0 found many answers but stil didnt get what i'm looking for, so, i have two installers for a program , 32 bit.exe and 64 bit.exe, i want to install the program via batch script to the corresponding OS bit, a batch script that detects if the current windows is 32 bit, then installs the 32 bit setup and vice versa, also i want a flexible script, like if i have a crack for that program and also i want to copy the crack to the program directory after the installed program, so the script must contain a labelled " :x86 " and " :x64 " sections, and after the bit detection the appropriate commands from the corresponding sections should run.. here's a sample script; @ECHO OFF IF EXIST "%programfiles(x86)%" (GOTO 64-Bit) ELSE (GOTO 32-Bit) :32-Bit run 32 bit commands GOTO END :64-Bit run 64 bit commands GOTO END :END but i dont want the end command in the script, because i may add more commands in the same script....! hope you got my point , BATCH Guys :D , help me...!!! :rolleyes: Quote Link to comment Share on other sites More sharing options...
ExXxtreme Posted December 19, 2013 Share Posted December 19, 2013 (edited) Hello,firstly, you could improve your script with the architecture check, see my script:@ECHO OFFIF %PROCESSOR_ARCHITECTURE%==x86 GOTO 32-Bit) ELSE (GOTO 64-Bit) :32-Bitrun 32 bit commands....run whatever...GOTO END :64-Bitrun 64 bit commands....run whatever...GOTO END :ENDAnd secondly, what do you mean with running more commands in same script? I wrote the script as I understood your question...greetZExXxtreme Edited December 19, 2013 by ExXxtreme Quote Link to comment Share on other sites More sharing options...
Dodel Posted December 19, 2013 Share Posted December 19, 2013 (edited) END is required in the script to stop it executing further commands or simply running in a loop constantly. What ExXxtreme has posted is exactly what you need, then all you need to do is fill in the 32 / 64 bit specific commands.ExXxtreme's code :-@ECHO OFFIF %PROCESSOR_ARCHITECTURE%==x86 GOTO 32-Bit <-- detect OS version and jump to 32bit or jump to 64bit if it's 64bit)) ELSE (GOTO 64-Bit) :32-Bitrun 32 bit commandsrun whatever...GOTO END <-- jump to end after executing 32 bit commands. (if this wasn't here it would try to then execute the 64bit commands also) :64-Bitrun 64 bit commandsrun whatever...GOTO END :END <- Exit script after running either 32bit of 64bit commands as per above, Edited December 19, 2013 by Dodel Quote Link to comment Share on other sites More sharing options...
CODYQX4 Posted December 19, 2013 Share Posted December 19, 2013 (edited) . Edited April 28, 2019 by CODYQX4 Quote Link to comment Share on other sites More sharing options...
eurobyn Posted December 19, 2013 Share Posted December 19, 2013 if exist %windir%\syswow64 (start /wait programX64 /s) else (start /wait programX86 /s)copy /y key for youre program "programs directory"exit a sample how it could be done. first it looks for architecture (X64 - X86) then when found it starts the corresponded (program)then it could copy the key or regfile in to that folder ! i hope it helps (working here with winrar) Quote Link to comment Share on other sites More sharing options...
NaJeEb303 Posted December 20, 2013 Author Share Posted December 20, 2013 Sorry guys for being too late,Hello,firstly, you could improve your script with the architecture check, see my script:@ECHO OFFIF %PROCESSOR_ARCHITECTURE%==x86 GOTO 32-Bit) ELSE (GOTO 64-Bit) :32-Bitrun 32 bit commands....run whatever...GOTO END :64-Bitrun 64 bit commands....run whatever...GOTO END :ENDAnd secondly, what do you mean with running more commands in same script? I wrote the script as I understood your question...greetZExXxtremeThanks ExXxtreme, your code is working for me, :showoff:END is required in the script to stop it executing further commands or simply running in a loop constantly. What ExXxtreme has posted is exactly what you need, then all you need to do is fill in the 32 / 64 bit specific commands.ExXxtreme's code :-@ECHO OFFIF %PROCESSOR_ARCHITECTURE%==x86 GOTO 32-Bit <-- detect OS version and jump to 32bit or jump to 64bit if it's 64bit)) ELSE (GOTO 64-Bit):32-Bitrun 32 bit commandsrun whatever...GOTO END <-- jump to end after executing 32 bit commands. (if this wasn't here it would try to then execute the 64bit commands also):64-Bitrun 64 bit commandsrun whatever...GOTO END:END <- Exit script after running either 32bit of 64bit commands as per above,Thanx for the explanation , it w0rked ... :rolleyes: Quote Link to comment Share on other sites More sharing options...
NaJeEb303 Posted December 20, 2013 Author Share Posted December 20, 2013 (edited) Hello,firstly, you could improve your script with the architecture check, see my script:@ECHO OFFIF %PROCESSOR_ARCHITECTURE%==x86 GOTO 32-Bit) ELSE (GOTO 64-Bit) :32-Bitrun 32 bit commands....run whatever...GOTO END :64-Bitrun 64 bit commands....run whatever...GOTO END :ENDAnd secondly, what do you mean with running more commands in same script? I wrote the script as I understood your question...greetZExXxtremeNOTE: If this gets run under WOW64 (a SFX likely will do this), the batch will be lied to and told the architecture=x86 hence causing it to treat the whole OS as 32 Bit.A common way floating around MDL is the following:@echo offsetlocal EnableExtensionssetlocal EnableDelayedExpansionreg.exe query "hklm\software\microsoft\Windows NT\currentversion" /v buildlabex | find /i "amd64" >nul 2>&1if %errorlevel% equ 0 set xOS=x64if /i "%PROCESSOR_ARCHITECTURE%"=="x86" if not defined PROCESSOR_ARCHITEW6432 set xOS=x86 if "%xOS%"=="x86" (echo "I AM 32 Bit OS") ELSE (echo "I AM 64 Bit OS")Note the PROCESSOR_ARCHITEW6432 check. If it is defined you know it (WOW64) is lying to you and you are really an x64 OS.You still if running under WOW64 may have issues with some commands, especially registry access, because of the redirection. This plagued the batch Office Toolkit V1.X with issues in this case and it was difficult to work around.thanx cody, but this script only shows me the Bitness of my OS, i.e 32 bit or 64 bit, can you edit the script for me so i can put my 32 bit and 64 bit commands in it, as provided by @ExXxtreme .... thanx ;) Edited December 20, 2013 by NaJeEb303 Quote Link to comment Share on other sites More sharing options...
CODYQX4 Posted December 20, 2013 Share Posted December 20, 2013 (edited) . Edited April 28, 2019 by CODYQX4 Quote Link to comment Share on other sites More sharing options...
NaJeEb303 Posted December 20, 2013 Author Share Posted December 20, 2013 thanx cody, but this script only shows me the Bitness of my OS, i.e 32 bit or 64 bit, can you edit the script for me so i can put my 32 bit and 64 bit commands in it, as provided by @ExXxtreme .... thanx ;)You want the GOTO? Usually I just embed my stuff inside the parenthesis and then I don't need an :END.@echo offsetlocal EnableExtensionssetlocal EnableDelayedExpansionreg.exe query "hklm\software\microsoft\Windows NT\currentversion" /v buildlabex | find /i "amd64" >nul 2>&1if %errorlevel% equ 0 set xOS=x64if /i "%PROCESSOR_ARCHITECTURE%"=="x86" if not defined PROCESSOR_ARCHITEW6432 set xOS=x86 if "%xOS%"=="x86" (x86 Command 1...x86 Command 100) ELSE (x64 Command 1...x64 Command 100)Thank you s0 much man.., now i g0t what i wanted..., u r0ck.. thnx agn..! :showoff: :rolleyes: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.