Forum Discussion

simonaferrara's avatar
simonaferrara
Frequent Contributor
3 years ago

Verify if a program is installed

 Hi all,

 

someone know if there could be a method to check if a program is installed?

 

During a test, I'm installing an msi, and I would like to verify if the program belongs to the list of the installed programs within the operating system (that is: the programs that I see within "Control Panel -> Programs and Features").

 

Thanks!

Simona

3 Replies

    • simonaferrara's avatar
      simonaferrara
      Frequent Contributor

      Hi, 

       

      anyone have got other ideas? 

       

      I can check the processes related to the application (as mattb explain) but this check is currently not enough, I would like to find a way to check if the application appears within the "Program and Feature" list.

       

      Thanks

      Simona

      • Raviavi's avatar
        Raviavi
        Occasional Contributor

        Hi Simona, 

         

        This is also an option using powershell script, but check the feasibility from your end

         

        ****************** Test Complete Code***************************************

        function CheckProgramInstalled()
        {
        var WSH = Sys["OleObject"]("WScript.Shell");
        var objExec = WSH["Exec"]("powershell -file C:\\****\\PowerscriptName.ps1");
        objExec ["StdIn"]["Close"]();
        var strOutput = objExec ["StdOut"]["ReadAll"]();
        Log["Message"](strOutput);
        }

        ****************** Test Complete Code***************************************

         

        in the above code power script(PS1 file - C:\\****\\PowerscriptName.ps1) is being used, you could create that file with below code using node pad and save as .ps1 extension or using powershell ise or VS CODE

         

        $software = "PROGRAM  NAME THAT YOU ARE SEARCHING";
        $installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $software }) -ne $null

        If(-Not $installed) {
        Write-Host "'$software' is not installed";
        } else {
        Write-Host "'$software' is installed."
        }

         

        It works if machine is 64 bit

         

        Else you can check using below in 2nd line of powershell script - I have not tried this

        HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstal  in 2nd line of powershell script