You have to detect the architecture and you logic will need to be different for 32\64-bit. Here is an example of a script that will search for installed software on a system and if it's a 64-bit system then it will search both software keys for the software:
Const HKLM = &H80000002
Set objWSHSHell = WScript.CreateObject("WScript.Shell")
Set objReg = GetObject("winmgmts:!root/default:StdRegProv")
If Is64Bit = True Then
arrSearchKeys = Array("SOFTWARE\Wow6432Node", "SOFTWARE")
Else
arrSearchKeys = Array("SOFTWARE")
End If
For Each strKey in arrSearchKeys
Call Uninstall_Software("UltraEdit 14.20", strKey)
Next
Function Uninstall_Software(search_string, search_key)
'On Error Resume Next
strUninstallKey = search_key & "\Microsoft\Windows\CurrentVersion\Uninstall"
objReg.EnumKey HKLM, strUninstallKey, arrSubKeys
For Each strSubKey In arrSubKeys
objReg.GetStringValue HKLM, strUninstallKey & "\" & strSubKey, "DisplayName", strDispName
objReg.GetStringValue HKLM, strUninstallKey & "\" & strSubKey, "DisplayVersion", strVer
objReg.GetStringValue HKLM, strUninstallKey & "\" & strSubKey, "UnInstallString", strUnInstall
If Instr(Ucase(strDispName), UCase(search_string)) Then
strUninstall = strUninstall & " /qn /norestart" 'Add any switches needed
WScript.Echo "Running command: " & strUninstall
' errReturn = objWSHShell.Run(strUnInstall, 0, True)
' If errReturn = 0 Then
' 'Successfully uninstalled
' Else
' 'Removal failed
' End If
End If
Next
End Function
Function Is64Bit()
Is64Bit = False
Dim colOS : Set colOS = GetObject("WinMGMTS://").ExecQuery("SELECT AddressWidth FROM Win32_Processor",, 48)
Dim objOS
For Each objOS In colOS
If objOS.AddressWidth = 64 Then Is64Bit = True
Next
End Function