/build/static/layout/Breadcrumb_cap_w.png

WiseScript Include File to determine if an MSI's Product Code has been installed..

I noticed that we were routinely trying to determine if an application was installed on a pc in the middle of our wisescript. So I determine to make that function an "include file". This means that it would need to be generic enough to not need editing, and could be added when ever you needed it to a script and it function correctly. The following sections can be cut and pasted into your wisescript to have it function like it does for us.

FYI, I call the include file, AppSearch it will become its own WSE and needs to reside in the same folder, or subfolder off of the location where you main script is located.

EX:

Root\MainScript.wse, Root\CActions\AppSearch.wse

::THE Include File::

item: Remark
  Text=<<<<<<<<<<<<Check if PRODCODE is INSTALLED>>>>>>>>>>>>>>
end
item: Call DLL Function
  Pathname=%SYS32%\msi.dll
  Function Name=MsiQueryProductStateA
  Argument List=40PRODCODE
  Return Variable=0INSTALL_STATE
  Flags=00100000
end
item: Set Variable
  Variable=APPINSTALLED
  Value=DontKnowYet
end
item: If/While Statement
  Value=(INSTALL_STATE = 5) OR (INSTALL_STATE = 2)
  Flags=00001101
end
item: Set Variable
  Variable=APPINSTALLED
  Value=YES
end
item: End Block
end
item: Set Variable
  Variable=PRODCODE
  Value=%RESET%
end

::The Variables needed in your main Script to make it work::

item: Set Variable
  Variable=PRODCODE
  Value=ADD PRODUCT CODE HERE
end
item: Set Variable
  Variable=RESET
  Value=%PRODCODE%
end

::When you need to call AppSearch Function::

item: Include Script
  Pathname=.\CActions\AppSearch.wse
end
item: If/While Statement
  Variable=APPINSTALLED
  Value=YES
end

The AppSearch will do the following if you want to follow the logic...

It will call the msi.dll and run a function called MsiQueryProductStateA and look for your variable PRODCODE to be filled out. Just paste in the whole GUI string with both {} included.

Then it gets the INSTALL_STATE value from the Function, and if its set to 5 or 2 (which means advertized, or actually installed on the pc) it will set the APPINSTALLED variable to equal YES. Lastly it will reset the PRODCODE variable back to the original value. The reason for this is so that you can search for more than one product by putting "Set Variable PRODCODE={newSoftwareProductCode} each time you add the Include section to your script. The reason I had it Reset, was that I used the main PRODCODE to have a generic uninstall string to be run against the main product. If you dont keep the reset in there, then everytime you set PRODCODE to = something else then it would become the new value. It also keeps the Include file Modular.

If you use more than one PRODCODE value you could use it like this... Lets say you wanted to see that Adobe Reader, .NET Framework 4.0, and Microsoft Visual C++ 2005 Redistributable were all installed before you continued to the next step of your installation. Now you can. After each "If APPINSTALLED = YES" then you could set a new value.

I hope this helps, and if you have suggestions, questions, or comments please dont hesitate to post.


Comments

This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ