3

Currently I am messing around with a Click-Once WPF application. That application is some third-party application that was not developed by me. I also do not have access to its sources.

It is run on a Windows server periodically and automatically (using a self made launcher written in standard C++) by executing the corresponding *.appref-ms link that was placed in the start menu path on installation of the application. This works fine.

Due to periodically arising problems with that application my launcher needs to wipe all configuration files before starting it so I get a well defined run at all times. Those files are placed in one of the application's folders. That config path for its settings reads like this (I found it by searching the AppData tree manually):

C:\Users\<UserName>\AppData\Local\Apps\2.0\Data\WM4WPKCW.P5Z\67QVXD6C.0NT\<app>_f6187a2321850a68_0003.0004_1a67f9f1633c43fc\Data\AppFiles\

Please note that this config path is pretty different from the application path (which uses differently named folders):

C:\Users\<User>\AppData\Local\Apps\2.0\5HN2CKMO.MPL\YOL20MYR.O8L\<app>_f6187a2321850a68_0003.0004_f6ab8c93b3a43b7c\

Since this config path changes on each update of the Click-Once application I need to find it by code (preferably C++) automatically. Unfortunately I could not figure out a way to do this.

How can I make my launcher find the config path of the Click-Once application based on its *.appref-ms file?

Silicomancer
  • 8,604
  • 10
  • 63
  • 130

1 Answers1

1

From Raghavendra Prabhu’s blog entry “Client Settings FAQ”:

If you want to get to the path programmatically, you can do it using the Configuration Management API (you need to add a reference to System.Configuration.dll). For example, here is how you can get the local user.config file path:

Configuration config =  
    ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
Console.WriteLine("Local user config path: {0}", config.FilePath);

The code is C# (evidently), but shouldn't be that hard to translate to C++/CLI.

Raghavendra Prabhu further writes:

If you need to store the settings in a different location for some reason, the recommended way is to write your own SettingsProvider. This is fairly simple to implement and you can find samples in the .NET 2.0 SDK that show how to do this. Keep in mind however that you may run into the same isolation issues mentioned above .

Disclaimer: I have not tested any of this.

Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
  • I am not the developer of the Click-Once application. I wrote a C++ (non-CLI) launcher that starts some third-party Click-Once application. The only thing my launcher knows about that third-party application is the *.appref-ms file path. Now I need a way to find the actual Click-Once application path using that *.appref-ms file only. Is my question unclear regarding this or is your answer helpful in a way I do not understand? – Silicomancer Dec 14 '14 at 14:16
  • I edited my questions. Sorry for not asking clearly. I wonder if I should start a new question with the rephrased text. – Silicomancer Dec 14 '14 at 14:33
  • Oh sorry, I can be a little thick sometimes. Didn't see that it was 3rd party app. Anyway, worth posting the above info, I think, since it can be useful to people getting here via google. – Cheers and hth. - Alf Dec 14 '14 at 16:13