Greg Saladino
Greg Saladino

Reputation: 87

ClickOnce Settings Not Found When Run from Command Line

I have a Windows Forms app that is deployed through ClickOnce. In the app, I take advantage of the application settings to store basic connection information. In the two years and 200+ updates since I've published the app and it's been in daily use, I've had no problems with individual users modifying their own settings, and having those settings retained when the application is relaunched and updated.

However, I am working on adding a feature into the app that allows for certain tasks to be scheduled in the Task Scheduler. Everything works fine (the task is scheduled, and the application is called with the correct parameters passed) however when the program is launched, the settings are not read.

I can replicate this by manually launching the application directly from the command line. The application opens, but the only settings available are the settings that shipped with the application initially.

My end question is this: How can I call my ClickOnce app from the command line and have it open the same way as if I'd launched it from the start menu?

Thanks!!

Upvotes: 0

Views: 270

Answers (2)

Greg Saladino
Greg Saladino

Reputation: 87

Looks like the answer is to point the Task Scheduler to launch the .appref-ms file that is found in the start menu shortcut. You can't just point to the .exe file.

Upvotes: 1

KeithN
KeithN

Reputation: 434

This is most likely caused by the Command line launching the ClickOnce App under a different user.

Try launching the ClickOnce from Command line or Task scheduler, and loading up task manager and seeing which user the app is running. If it is running on a user other than the user you are logged in as, then you can either log in as the user it is running under (if it's not a system user) and setting what settings you want, or you could try impersonating the desired user through task scheduler.

If none of that is applicable, you could add a Command line switch that, if no settings are found, saves a set of default settings that match what you want.

Upvotes: 0

Related Questions