MSFN Forum: how can I identify if OS is 32 bit or 64 bit in batch file? - MSFN Forum

Jump to content



Unattended CD/DVD Guide Homepage · MSFN Forum Rules

Welcome to the Applications Installs forum. Make sure you read the forum rules before you start posting.

Links/Requests to warez and/or any illegal material (porn, cracks, serials, etc..) will not be tolerated. Discussion of circumventing WGA/activation/timebombs/keygens or any other illegal activity will also not be tolerated.

We try our best to keep this forum clean of illegal content. If you see any illegal activity use the "report" button you find in every post to report the specific post to the moderators. If you ignore any of the rules you will be banned without notice.

Read Forum Rules
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

how can I identify if OS is 32 bit or 64 bit in batch file? Rate Topic: -----

#1 User is offline   DungFu 

  • Group: Members
  • Posts: 8
  • Joined: 24-September 08

Posted 08 February 2009 - 08:14 PM

the question is in the title, I am not sure how to do it. Help would be greatly appreciated!


#2 User is offline   darks0ul 

  • Member
  • PipPip
  • Group: Members
  • Posts: 142
  • Joined: 15-September 04

Posted 09 February 2009 - 05:46 PM

 
>echo %processor_architecture%
AMD64 


Note that this will not work for a script like RunOnceEx.cmd or similar that are called from cmdlines.txt

I mean, this variable is set when the computer makes the first boot after the installation.
Otherwise, try checking if %WinDir%\SysWOW64 exists...

Or you can use AutoIt (@OSArch constant)

#3 User is offline   Jito463 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 442
  • Joined: 01-July 04

Posted 29 April 2009 - 09:36 AM

I know this is an older post, but here's what I've always used:

%ProgramFiles(x86)%
IF ERRORLEVEL = 1 GOTO x64
IF ERRORLEVEL = 0 GOTO x86


If it exists (ERRORLEVEL = 1), then it runs the 64-bit (x64) commands

If it does not exist (ERRORLEVEL = 0), then it runs the stanard 32-bit (x86) commands.

Of course, you could do the same with SysWow64 instead. Just pick any file or folder that would only exist in a 64-bit OS.

#4 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 29 April 2009 - 11:49 AM

View PostJito463, on Apr 29 2009, 04:36 PM, said:

I know this is an older post, but here's what I've always used:

%ProgramFiles(x86)%
IF ERRORLEVEL = 1 GOTO x64
IF ERRORLEVEL = 0 GOTO x86


If it exists (ERRORLEVEL = 1), then it runs the 64-bit (x64) commands

If it does not exist (ERRORLEVEL = 0), then it runs the stanard 32-bit (x86) commands.

Of course, you could do the same with SysWow64 instead. Just pick any file or folder that would only exist in a 64-bit OS.

I'd suggest not to use that syntax…
IF ERRORLEVEL = n is first of all not correct
Also an errorlevel of 0 means that errorlevel was 0 or greater which in all cases would be true.

This would probably replace your command better
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)


#5 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 9,105
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 29 April 2009 - 01:01 PM

Just for the record.

Errorlevel in NT based systems is a variable:
http://www.911cd.net...showtopic=18512
http://www.robvander.../errorlevel.php

jaclaz

#6 User is offline   Jito463 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 442
  • Joined: 01-July 04

Posted 09 May 2009 - 09:12 AM

View PostYzöwl, on Apr 29 2009, 12:49 PM, said:

View PostJito463, on Apr 29 2009, 04:36 PM, said:

I know this is an older post, but here's what I've always used:

%ProgramFiles(x86)%
IF ERRORLEVEL = 1 GOTO x64
IF ERRORLEVEL = 0 GOTO x86


If it exists (ERRORLEVEL = 1), then it runs the 64-bit (x64) commands

If it does not exist (ERRORLEVEL = 0), then it runs the stanard 32-bit (x86) commands.

Of course, you could do the same with SysWow64 instead. Just pick any file or folder that would only exist in a 64-bit OS.

I'd suggest not to use that syntax…
IF ERRORLEVEL = n is first of all not correct
Also an errorlevel of 0 means that errorlevel was 0 or greater which in all cases would be true.

This would probably replace your command better
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)



It's always worked for me, which is why I used it, but I will admit your version is much cleaner and will probably switch to that. By the way, in your version, the ( ) around the GOTO commands doesn't need to be there.

#7 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 09 May 2009 - 11:54 AM

View PostJito463, on May 9 2009, 04:12 PM, said:

%ProgramFiles(x86)%
IF ERRORLEVEL = 1 GOTO x64
IF ERRORLEVEL = 0 GOTO x86


If it exists (ERRORLEVEL = 1), then it runs the 64-bit (x64) commands

If it does not exist (ERRORLEVEL = 0), then it runs the stanard 32-bit (x86) commands.
<snip />


<snip />

It's always worked for me, which is why I used it.

It is wrong, the first line would produce an error every time
'expanded or otherwise variable' is not recognized as an internal or external command, operable program or batch file.

For the next line you could have used among others:
IF ERRORLEVEL 1 GOTO x64
IF %ERRORLEVEL%==1 GOTO x64
IF %ERRORLEVEL% EQU 1 GOTO x64
IF %ERRORLEVEL% GEQ 1 GOTO x64
IF NOT ERRORLEVEL 0 GOTO x64

Jito463 said:

By the way, in your version, the ( ) around the GOTO commands doesn't need to be there.
Are you sure?

Run this code in your console window
IF EXIST "%PROGRAMFILES(X32)%" (ECHO/32BIT) ELSE (ECHO/64BIT)
Result is:
64BIT


Now run this in your console window
IF EXIST "%PROGRAMFILES(X32)%" ECHO/32BIT ELSE ECHO/64BIT
What is the result?

#8 User is offline   Sonic 

  • Sonic
  • Group: Patrons
  • Posts: 1,600
  • Joined: 04-December 03

Posted 11 May 2009 - 06:40 AM

... don't try to fight with yzöwl , he's always win at "batch" :P ...

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy