powershellwindows-installerexeremote-serversilent-installer

Powershell silent installation issue


What will happen if we try to install a software using powershell which has already installed in a server . For an example I already have notepad++ in my server, Now I try to install same notepad++ version in my server using powershell. Then what will be the output?. Besides, Is there a way that I could find whether a software has already installed in server or not.


Solution

  • There are many kinds of installers, but most add records in the Add / Remove list of programs, but there are no guarantees. Here is C++ code to scan the registry and check via WMI. You can use scripts instead of course, but it is not an exact science to find what is installed - some installers are very custom and non-standard and follow few guidelines.

    Registry Entries:

    MSI Packages:

    For MSI packages there are ways to check whether the exact same version or a related version is installed. If you have the product code of the MSI, you can simply check whether it is installed like this:

    Dim installer : Set installer = CreateObject("WindowsInstaller.Installer")
    MsgBox installer.ProductState("{00000000-0000-0000-0000-000000000001}") ' <= PRODUCT CODE
    

    Longer sample linked here.

    You can find the product code for an installed MSI using several approaches: How can I find the product GUID of an installed MSI setup?

    If you have the upgrade code for a family of MSIs you can use the RelatedProducts method to find out whether a related product is installed:

    Set installer = CreateObject("WindowsInstaller.Installer")
    Set upgrades = installer.RelatedProducts("{UPGRADE-CODE-GUID-HERE}")
    
    For Each u In upgrades
       MsgBox u, vbOKOnly, "Product Code: "
    Next
    

    How can I find the Upgrade Code for an installed MSI file?. You can get the upgrade code for an MSI due to be installed by looking in the Property table using Orca.

    Pragmatic Approaches:

    One option is to identify a key file from each installation and check for its existence using any language you want - scripting will do.

    Set fso = CreateObject("Scripting.FileSystemObject")
    MsgBox fso.GetFileVersion("C:\Windows\System32\vcruntime140.dll")
    

    The above script snippet from this rant on how to find the installed VCRedist version.


    Link: