0
$\begingroup$

I am writing a WinForms .NET program and I want to check whether Blender software has been installed in the local computer.

How to check if Blender is installed on a computer (32 bit & 64 bit)?

At the moment, I only can think of checking if Blender folder exists in the Program Files (for 32 bit) / Program Files x86 (for 64 bit).

However, I would prefer other methods of checking if Blender is installed instead of checking the Blender installation folder in Program Files.

Thank you

$\endgroup$
4
  • $\begingroup$ blender doesn't have an installer , you could perhaps check the win registry and see with what program .blend files are associated , or if the folder `$USERNAME\AppData\Roaming\Blender Foundation\Blender\2.xx` exists, but those are not reliable since the user has to run blender at least once. $\endgroup$ – user2816 May 20 '16 at 11:03
  • $\begingroup$ @R00t What do you mean "blender doesn't have an installer"? $\endgroup$ – Ray Mairlot May 20 '16 at 15:28
  • $\begingroup$ @R00t There are both versions - Blender with installer and portable Blender. $\endgroup$ – Jaroslav Jerryno Novotny May 20 '16 at 15:32
  • $\begingroup$ sorry I worded that wrong, I meant to say blender was not meant to be installed but to be used more like a portable software. the installer is just a convenience tool, it extracts blender into a predefined path and prompts users if them want to associate the .blend extension to blender. photoshop for example installs itself deep into the root of the machine (like context menu,additional programs ,etc). $\endgroup$ – user2816 May 20 '16 at 18:58
2
$\begingroup$

You are talking about windows machine, I suppose.

The answer is here: Detecting installed programs via registry

The only thing specific to Blender is what to look for in registry:

  • HKEY_CURRENT_USER\Console\paths_to_blender_executables - you will find here entries for ALL Blenders (versions installed or only executed from .zip archives). There is no assurance that Blender is still on the system though, just that it was in some point in time

  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.blend - here is the Blender reference to .blend file. Also can be misleading if Blender was not uninstalled properly.

  • HKEY_LOCAL_MACHINE\SOFTWARE\BlenderFoundation\ or HKEY_CURRENT_USER\Software\Blender Foundation\ - both are what you are looking for

$\endgroup$
2
  • $\begingroup$ I do not have HKEY_LOCAL_MACHINE\SOFTWARE\BlenderFoundation, instead I have: HKEY_CURRENT_USER\Software\Blender Foundation\ or HKEY_LOCAL_MACHINE\SOFTWARE\Classes\blendfile\shell\open\command. Would that be alright for me to perform the registry test using any of the registry above? Thank you. $\endgroup$ – hunterex May 23 '16 at 14:34
  • $\begingroup$ @hunterex Yes, indeed you should check both the local_machine and current_user registry keys. I'll add it to the answer. $\endgroup$ – Jaroslav Jerryno Novotny May 23 '16 at 14:36
1
$\begingroup$

for Blender 2.81 on Windows 10:

"HKEY_CURRENT_USER\Software\Blender Foundation\Blender"

did not provide the installed location, I ended up retrieving it from:

"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\blendfile\shell\open\command"

and then programmatically removing the %1 part.

$\endgroup$
0
$\begingroup$

The only way to be sure blender exists is to search the HD.

On windows, if a user downloads and runs the installer, then you can find registry entries. If a user downloads the zip version of blender then the copy of blender they extracted, which may be on the desktop or somewhere in their home folder, could be the only trace that blender exists. After extracting they may optionally set the registry entries to associate .blend files with the blender binary so that a registry entry exists.

You can also end up with multiple versions of blender installed, the newest version that the user wants to use may be the copy extracted on the desktop, not the one in program files.

I would suggest searching a few possible locations for blender such in program files and the desktop for the initial default path but ask the user to choose the blender location.

$\endgroup$
3
  • $\begingroup$ Blender in a folder downloaded from a .zip is not installed. When a program is installed it leaves a trace in registry and you don't have to search the whole hdd for it. Since the question is about finding installed Blender, I object that finding non-installed Blender does not answer the question:) $\endgroup$ – Jaroslav Jerryno Novotny May 20 '16 at 15:27
  • $\begingroup$ Many users don't distinguish the technical difference between using an installer and unzipping, if it is on the computer then it has been "installed" on the computer and is available. Also if the installer is used you have more than a 90% chance that it is in program files and easily found without checking the registry. Mostly I wanted to highlight the fact that checking locations and registry entries does not mean that blender doesn't exist, even if you do find it - it is best to ask the user which copy to use. $\endgroup$ – sambler May 20 '16 at 15:40
  • $\begingroup$ Searching the hdd for a file can be a long process - it may take dozens of minutes. So I woulnd't find it as an option. I would just say that blender is not installed if it is not in registry, which is actually correct statement. $\endgroup$ – Jaroslav Jerryno Novotny May 20 '16 at 15:48
0
$\begingroup$

Either use the Windows Installer COM interface or query WMI information from the Win32_Product class.

Windows Installer

        static void GetBlenderInstallationFromMsi()
    {
        Installer installer;

        installer = (Installer)Activator.CreateInstance(Type.GetTypeFromProgID("WindowsInstaller.Installer"));
        var products = installer.Products;
        foreach (string productID in products)
        {
            string productName = installer.get_ProductInfo(productID, "ProductName");

            if (String.Compare(productName, "Blender", StringComparison.OrdinalIgnoreCase) == 0)
            {
                string blenderPath = installer.get_ProductInfo(productID, "InstallLocation");

                Console.WriteLine(productID);
                Console.WriteLine(productName);
                Console.WriteLine(blenderPath);
            }

        }


    }

WMI

    public static void GetBlenderInstallationFromWmi()
    {
        // Create a query 
        SelectQuery query =
           new SelectQuery("SELECT * FROM Win32_Product WHERE Name LIKE 'Blender'");

        // Initialize an object searcher with this query
        ManagementObjectSearcher searcher =
           new ManagementObjectSearcher(query);

        // Get the resulting collection and loop through it
        foreach (ManagementObject product in searcher.Get())
        {
            Console.WriteLine(product["Name"]);
            Console.WriteLine(product["Version"]);
            Console.WriteLine(product["InstallLocation"]);
        }
    }
$\endgroup$
0
$\begingroup$

An option might be to check how windows search feature works. Since you can type in Blender and it returns the possible matches. Could check to see if it's type application and return true if it's found.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.