简体   繁体   中英

Accessing folder information about clickonce application

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 ac# 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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM