Page 2 of 4 <1234>
Topic Options
#208344 - 2014-01-20 08:02 PM Re: Check for 32 or 64 bit [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I think the @onwow64 would be a good starting point for that.

I am not really sure why would one want to do a searchreg() though. I have 32bit office 2010 and that searchreg() code above will say I have 64bit just because office 2010 does come with some 64bit components.
for the registry route you would need to search for specifically: {9XXX0000-AAAA-XXXX-B000-0000000FF1CE}

where X-denotes stuff you don't care about and B stands for bitness, 1 being 64bit office.
the AAAA you need to filter against as you want only the office key, not the individual components, so search for one of the following values in the AAAA field:
0011 Microsoft Office Professional Plus
011D Microsoft Office Professional Plus Subscription
0012 Microsoft Office Standard
0013 Microsoft Office Home and Business
0014 Microsoft Office Professional
002F Microsoft Office Home and Student
_________________________
!

download KiXnet

Top
#208369 - 2014-01-23 09:37 PM Re: Check for 32 or 64 bit [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
No, don't forget that x64 will redirect calls so that needs to be accounted for. Also I'm mentioning the path where to look for the EXE not just if the path exists as it will exist with a few files in it on x64 even if you have the 32-bit Office installed. But if you have the 64-bit version of Office installed then the EXE files will be in the C:\Program Files\Microsoft Office\Office15 folder. IF you find Excel, Word etc in the C:\Program Files\Microsoft Office\Office15 folder then you have to be running the 64-bit version of Office.

Top
#208372 - 2014-01-23 10:53 PM Re: Check for 32 or 64 bit [Re: NTDOC]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
So are you saying this...

 Code:
if exist("C:\Program Files\Microsoft Office\Office15\WinWord.exe")
  ? "Office 64bit"
else
  ? "Office 32bit"
endif


...will produce the correct results whether it is Windows 7 32bit or Windows 7 64bit?


Top
#208374 - 2014-01-24 03:27 AM Re: Check for 32 or 64 bit [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Have not tested to confirm but in a nutshell yes something like that.
Top
#208376 - 2014-01-24 09:28 AM Re: Check for 32 or 64 bit [Re: NTDOC]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
No, because that code would return Office 64-bit on a 32-bit version of Windows.
Top
#208377 - 2014-01-24 09:32 AM Re: Check for 32 or 64 bit [Re: Arend_]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
 Code:
If EXIST(%%ProgramFiles(x86)%%)
  ;Windows = 64-bit, check for Office
  If EXIST("%%ProgramFiles%%\Microsoft Office\Office15\WinWord.exe")
    ? "Office 64bit")
  EndIf
  If EXIST("%%ProgramFiles(x86)%%\Microsoft Office\Office15\WinWord.exe")
    ? "Office 32bit"
  EndIf
Else
  ;Windows = 32-bit, if there is office, office will be 32-bit
EndIf

Top
#208378 - 2014-01-24 01:20 PM Re: Check for 32 or 64 bit [Re: Arend_]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
I've got to go with Arend on this one, since a 32-bit platform will only have a "Program Files" path.. MS might have done better to name the new folder "Program Files(x64)". \:\)

Something like this will work but doesn't validate the presence of the 32-bit app:
 Code:
If %PROCESSOR_ARCHITECTURE% = 'x86'
  'Office 32bit' @CRLF			; Can't be 64-bit on x86 platform
Else
  ; 64-bit platform - see which version of Office is present
  If Exist('C:\Program Files\Microsoft Office\Office15\WinWord.exe')
    ; app found in 64-bit location, is x64
    'Office 64bit' @CRLF
  Else
    'Office 32bit' @CRLF
  EndIf
EndIf
As a UDF, which returns 0 (not found), 32, or 64:
 Code:
Function OfficeBits()

  If %PROCESSOR_ARCHITECTURE% = 'x86'
    $OfficeBits = 32			; Can't be 64-bit
  Else
    ; 64-bit platform - see which version of Office is present
    If Exist('C:\Program Files\Microsoft Office\Office15\WinWord.exe')
      ; found in 64-bit path
      $OfficeBits = 64
    Else
      If Exist('C:\Program Files(x86)\Microsoft Office\Office15\WinWord.exe')
        $OfficeBits = 32      ; found in 32-bit path
      Else
        $OfficeBits = 0       ; not found!
      EndIf
    EndIf
  EndIf

  Exit 0

EndFunction
For a proper function, the install path should probably be gleaned from the registry. This still isn't foolproof as I can do a custom install to, say, "D:\Programs" that will render this method useless. It's probably OK for most of the installations out there.

The WMIInstalledProducts UDF (download from my web site) returns the product GUID. If the "Microsoft Office" product is found, there is a value in the GUID that returns the product bitness.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#208379 - 2014-01-24 02:18 PM Re: Check for 32 or 64 bit [Re: Glenn Barnas]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
I think that also has problems because it is only looking for Office15. I think one would have to instead search for winword.exe such as:
 Code:
dir "c:\program files\microsoft office\winword.exe" /s /b
If it finds it, then it is 64 bit else repeat with inserting "(x86)" into the string.

Top
#208380 - 2014-01-24 03:11 PM Re: Check for 32 or 64 bit [Re: BradV]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Yup, which is why I'd use the WMIInstalledProducts (or similar WMI calls) to get a list of apps, then search for the Microsoft Office product, then check the "bitness" flag. Does all the work to detect the product, version, and bitness.

Of course, this has been a discussion about general methods, with little work done to create an all-encompassing process. So - are you up to writing this and posting a UDF, Brad?? \:D

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#208381 - 2014-01-24 05:13 PM Re: Check for 32 or 64 bit [Re: Glenn Barnas]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
How about this version?

There are still holes (office installed in irregular path, etc..), but should work for the majority.

 Code:
Function OfficeBits()
   $version = Right(ReadValue("HKCR\Word.Application\CurVer", ""), 2)
   If Len($version)
      If @OnWow64 AND Exist("C:\Program Files\Microsoft Office\Office"+$version+"\winword.exe")
         $OfficeBits = 64
      Else
         $OfficeBits = 32
      Endif
   Else
      $OfficeBits = 0
   Endif
EndFunction

Top
#208382 - 2014-01-24 06:24 PM Re: Check for 32 or 64 bit [Re: ShaneEP]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Is WMI always guaranteed to be installed and active? Before writing something to utilize that, we should get that question answered. Given that, I'm more than happy to work on it. \:\)
Top
#208383 - 2014-01-24 07:06 PM Re: Check for 32 or 64 bit [Re: BradV]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
My issue with WMI, is that it takes a really long time. Probably about 45 seconds to a minute on this XP machine Im on.
Top
#208384 - 2014-01-24 07:16 PM Re: Check for 32 or 64 bit [Re: ShaneEP]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Maybe you need new hamsters? \:\)
Top
#208385 - 2014-01-24 07:43 PM Re: Check for 32 or 64 bit [Re: BradV]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
No - I have new (well fed) hamsters - i7 3GHz 8-core workstation w/ 12G and it takes 25-35 seconds to do a WMI Products query. That's why I suggested doing the collection via a Run of an independent job with the inventory script I posted in the vault. I can't imagine doing that query over the LAN!

With my Kix HelpDesk utility, the tool takes an average of 45 seconds to query a remote workstation without any agents. Using KixForms & sockets, I can send a request, perform the query locally, and return the array in less than half of the time - often 12-15 seconds. I don't do a Products query, which seems to take forever on any system.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#208391 - 2014-01-25 06:37 PM Re: Check for 32 or 64 bit [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I am actually leaning towards the registry query, even if it is little complex with all the sku options, it atleast works.
looking for a path that might not even be there since user can change the path during installation is utterly unreliable.

edit,
and what comes to the wmi query, does that not tricker the software inventory refresh?
you know, the one that spills 100 lines of event lines in the eventlog?
_________________________
!

download KiXnet

Top
#208393 - 2014-01-25 07:20 PM Re: Check for 32 or 64 bit [Re: Lonkero]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
I would vote for the registry lookup as well honestyl...I was just too lazy to look up all the possible GUID values.
Top
#208394 - 2014-01-25 09:11 PM Re: Check for 32 or 64 bit [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
done it.will post in a sec.
_________________________
!

download KiXnet

Top
#208396 - 2014-01-25 09:23 PM Re: Check for 32 or 64 bit [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
there ya go: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=208395
_________________________
!

download KiXnet

Top
#208397 - 2014-01-25 09:51 PM Re: Check for 32 or 64 bit [Re: Lonkero]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Well done sir. I guess there weren't as many GUIDs as I thought. I was drastically over complicating it in my head.

It works on Win XP with office 2010 32 bit installed. Will try on Win 8 with 64 bit later. But I don't see why it wouldn't work.

Top
#208398 - 2014-01-25 10:38 PM Re: Check for 32 or 64 bit [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
win8 breaks everything. should have added to the remarks that it isn't supported.

worked fine on win7 64bit with 32bit office.

and, if you only have word or excel or project or whatever (remember the works installations back in the day with word added?) this should not work as the code is looking for only office sku's and skipping single component ones.
_________________________
!

download KiXnet

Top
Page 2 of 4 <1234>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.074 seconds in which 0.025 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org