option explicit Const HKCR = &H80000000 const HKLM = &H80000002 Const msiInstallStateNotUsed = -7 Const msiInstallStateBadConfig = -6 Const msiInstallStateIncomplete = -5 Const msiInstallStateSourceAbsent = -4 Const msiInstallStateInvalidArg = -2 Const msiInstallStateUnknown = -1 Const msiInstallStateBroken = 0 Const msiInstallStateAdvertised = 1 Const msiInstallStateRemoved = 1 Const msiInstallStateAbsent = 2 Const msiInstallStateLocal = 3 Const msiInstallStateSource = 4 Const msiInstallStateDefault = 5 dim reg : set reg = getObject( "Winmgmts:root\default:StdRegProv" ) dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell") Dim installer : Set installer = Wscript.CreateObject("WindowsInstaller.Installer") dim x86keyPath : x86keyPath = "SOFTWARE\Wow6432Node\Aspentech\Setup" dim keyPath : keyPath = "SOFTWARE\Aspentech\Setup" 'is any aspen product installed WScript.Echo "Check if any aspen product installed ... Please wait ..." dim isanyATProdInstalled : isanyATProdInstalled = IsAnyAspenProdInstalled() if isanyATProdInstalled then WScript.Echo "One or more Aspen product(s) found on the computer. ASPENROOT is not reset. Please uninstall all AspenTech products before running this script." else ProcessRegEntries(x86keyPath) ProcessRegEntries(keyPath) end if WScript.Echo "Done." Function ProcessRegEntries(keyPath) on error resume next dim valueNames, types, valueName dim value dim i if reg.enumValues( HKLM, keyPath, valueNames, types ) = 0 then if isArray( valueNames ) then for i = 0 to UBound( valueNames ) valueName = valueNames(i) if lcase(left(valueName,9)) = "aspenroot" then reg.getStringValue HKLM, keyPath, valueName, value WScript.Echo "removing " & valueName & "=" & value reg.DeleteValue HKLM,keyPath,valueName end if next end if end if end function Function IsAnyAspenProdInstalled() on error resume next dim products : Set products = installer.Products dim publisher, product For Each product In products publisher = installer.ProductInfo(product, "Publisher") 'WScript.Echo installer.ProductInfo(product, "ProductName") & " -- " & publisher if lcase(left(publisher,5)) = "aspen" then WScript.Echo "Found " & installer.ProductInfo(product, "ProductName") & " -- " & publisher IsAnyAspenProdInstalled = true exit function end if publisher = "" Next IsAnyAspenProdInstalled = false end function