How to Check if Program is Installed

RPA primary simulates user inputs in software applications or uses API calls. To be able to perform this operation at all, these software applications, additional tools and programming languages are required on the robot machine. You have different options to deploy these, which are neccessary in the context of an automation process, on your robot machine. For example you can deploy the software as NuGet package or as Microsoft Installer (MSI). In this post I present one possibility how to verify the presence of software, on a robot machine, where the deployment is outside the control of the RPA platform.

First an approach of a comparison of advantages and disadvantages of using a NuGet package or Installer:

  Advantages Disadvantages
NuGet Package
  • The software applications are loaded from the orchestration when needed.
  • The software inventory must be specially adapted.
Installer
  • The software inventory can be used by default.
  • Software deployment and usage are administratively separated. This can lead to more licenses being installed than needed or to a higher monitoring effort.

It is to be estimated individually which way is the better one or whether perhaps a mixture is used, depending on the use case and the necessary software with its license conditions. If the case arises that necessary software applications may not be available on the robot machine, e.g. in the case of a massive scaling that was not foreseeable, here an approach for checking whether the software application is installed, i.e. entered in the Windows registry. Here an Invoke Code routine to read all software installations and to check if the desired one is present:

//-Begin----------------------------------------------------------------

string displayName;
string displayVersion;

DataTable dtUninstall = new DataTable();
dtUninstall.Clear();
dtUninstall.Columns.Add("displayName");
dtUninstall.Columns.Add("displayVersion");

Microsoft.Win32.RegistryKey[] regKeys = new Microsoft.Win32.RegistryKey[] {
  Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"),
  Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"),
  Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"),
  Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall")
};

foreach(Microsoft.Win32.RegistryKey regKey in regKeys) {
  try {
    foreach(String keyName in regKey.GetSubKeyNames()) {
      Microsoft.Win32.RegistryKey subkey = regKey.OpenSubKey(keyName);
      displayName = subkey.GetValue("DisplayName") as string;
      displayVersion = subkey.GetValue("DisplayVersion") as string;
      if(!String.IsNullOrEmpty(displayName)) {
        DataRow drUninstall = dtUninstall.NewRow();
        drUninstall["displayName"] = displayName;
        drUninstall["displayVersion"] = displayVersion;
        dtUninstall.Rows.Add(drUninstall);
      }
    }
  } catch {
    continue;
  }

}

dtUninstall.DefaultView.Sort = "displayName ASC";
dtUninstall = dtUninstall.DefaultView.ToTable();

foreach(DataRow line in dtUninstall.Rows) {
  if(line["displayName"].ToString().ToLower().Contains(Name.ToLower())) {
    if(!String.IsNullOrEmpty(Version)) {
      if(line["displayVersion"].ToString().Contains(Version)) {
        Available = true;
      }
    } else {
      Available = true;
    }
  }
}

//-End------------------------------------------------------------------

The input parameters are Name, this is the program name respectively a part of it, and optional the Version, this is the program version, respectively a part of it. The code delivers the availability as a boolean expression as output parameter.

The following example checks if Edge is available in version 102:

image

image

Certainly, the routine can also be extended to check a minimum version. The routine works in the compatibility modes Windows and Windows - Legacy.

Depending on whether a software application is available or not, the bot can now decide how to proceed.

CheckIfProgramIsInstalled.xaml (7.1 KB)

7 Likes

Hi @StefanSchnell,

Some desktop automations receive monthly updates. It will be very useful to check this and try to install the new version. Thanks for sharing.

Regards,
MY

1 Like

Super useful one ! :slightly_smiling_face::+1:

1 Like

@muhammedyuzuak

Hello Muhammed,
indeed, this is also a very interesting field of application for this approach, I haven’t even thought of it yet. Review of release statuses to ensure up-to-dateness in technical operations, great sugestion.
:slightly_smiling_face:
Best regards
Stefan

1 Like

Thank you @Nithinkrishna :slightly_smiling_face:

1 Like