9

Here's the problem:

I have two applications. One of them is a clickonce application that I do not have access to, and the other one is a c# program I'm designing. I need a way to track down the application folder where the app is installed by either the .appref-ms file in the start menu, or the token id/name found from within that file.

Is this possible? Is there a way to query the clickonce store for a list of applications and where they are installed to? Everything I have found refers to opening the process list and going to the process image location, but this is not possible if the program is not running.

Blue
  • 22,608
  • 7
  • 62
  • 92
  • Maybe this helps you to find the application http://stackoverflow.com/questions/908850/get-installed-applications-in-a-system – MrWombat May 19 '15 at 06:08
  • I do not think there is an easy way to do it, the names are obfuscated by design. You can search `C:\Users\xxxx\AppData\Local\Apps\2.0` folder to see what is in subfolders. – Vojtěch Dohnal May 19 '15 at 06:30

2 Answers2

4

ClickOnce store data in Windows registry key: HKEY_CURRENT_USER\Software\Classes\Software\Microsoft\Windows\CurrentVersion\Deployment

Registry key with application list: HKEY_CURRENT_USER\Software\Classes\Software\Microsoft\Windows\CurrentVersion\Deployment\SideBySide\2.0\StateManager\Applications

Serj-Tm
  • 16,581
  • 4
  • 54
  • 61
2

I don't know a way to query the ClickOnce store.

But as @Vojtěch Dohnal said. All ClickOnce applicaitons will be stored in C:\Users\xxxx\AppData\Local\Apps\2.0

We could imagine a solution who will, for each user, list all the executable files in the tree, and only save the last versions.

Here is an example code snippet (single user) :

var exes = Directory.EnumerateFiles(@"C:\Users\<user>\AppData\Local\Apps\2.0", "*.exe",
    SearchOption.AllDirectories);

var apps = new Dictionary<String, Tuple<String, Version>>();

foreach (var file in exes)
{
    var fileName = Path.GetFileName(file);

    Version v = null;
    Version.TryParse(FileVersionInfo.GetVersionInfo(file).FileVersion, out v);

    if (fileName == null || v == null) continue;

    if (!apps.ContainsKey(fileName))
    {
        apps.Add(fileName, new Tuple<string, Version>(file, v));    
    }
    else if (v > apps[fileName].Item2)
    {
        apps[fileName] = new Tuple<string, Version>(file, v);
    }
}

You'll find in the apps dictionary all the applications names as keys, and as values a Tuple containing the full path to the executable and it's version.

Didn't find another way to get the information, but i hope it'll do the job

Tried on my computer and it seems to work fine

If you know your application name, you can this way get the path to the last installed version.

If not but you know where the .appref-ms is, you'll have to open it, get the application manifest (the .application file published by ClickOnce) and get the executable name from the assemblyIdentity node.

Irwene
  • 2,807
  • 23
  • 48