Sign in to follow this  
Toolmaker

MSI Packages + Using VBScript to detect 64-bit

Recommended Posts

I got a weird issue with my MSI installer. We're using InstallShield Express to build our setup, and while the MSI package it generates is perfectly working, I'm having issues with detecting 32-bit / 64-bit machines. I wrote a small VBScript which checks the Windows Registry for the CPU architecture and based on the architecture, it'll remove either the 32-bit or the 64-bit executable from the installer. What I do is during initialization of the installer, I have a VBScript which does this:
On Error Resume Next

Set WshShell = CreateObject("WScript.Shell")

OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
Session.SetInstallLevel(0) ' Needed to re-calculate the installers requirements
Set Db = Session.Database

' Delete either the 32-bit or the 64-bit installation option, based on the current CPU Architecture
If (OsType = "x86") Then
	Set Vw = Db.OpenView("DELETE FROM `Feature` WHERE `Feature`.`Feature` = 'NewFeature4'") ' 64-bit option removed
	Call Vw.Execute
	Call Vw.Close
	Call Db.Commit
	
	'Call MsgBox("Removed 64-bit option")
Else
	Set Vw = Db.OpenView("DELETE FROM `Feature` WHERE `Feature`.`Feature` = 'NewFeature5'") ' 32-bit option removed
	Call Vw.Execute
	Call Vw.Close
	Call Db.Commit
	
	'Call MsgBox("Removed 32-bit option")
End if
	
' Let's re-calculate all install settings and make our changes propagate
Session.SetInstallLevel(0)

The script itself works fine. The 64-bit option doesn't show up when I'm running the installer. HOWEVER, after completing the installation, I see both the 32-bit and the 64-bit helper files(Which have different names), and I end up with the 64-bit EXE and DLL. In other words, it installs both executables, and the 64-bit end up being written last, thus overwriting the 32-bit files. When I rename my 64-bit files to name64.exe and name64.dll, I end up with both files. Any idea what's going on here? I appears to update the database, yet still installs both features. Toolmaker

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this