Reputation: 18178
Is it possible to find out whether your current .Net app has been launched using a shortcut or a Clickonce application reference (*.appref-ms) file? If so, how?
Some background: I am running into an issue using Microsoft Clickonce in which I cannot pass command line arguments to the application. It seems that this is the way the technology works by design. I was exploring different ways of passing this parameter; one of them was to have a set of different Clickonce Start Menu shortcuts.
Upvotes: 0
Views: 1241
Reputation: 50235
Try testing out the ApplicationDeployment.IsNetworkDeployed property. I know this will be true if it is a ClickOnce app but I'm not sure if it will be false in your situation.
Upvotes: 1
Reputation: 163327
I'm not sure what an "application reference file" is; do you mean like double-clicking the EXE file in Explorer or running the file from a command line?
There isn't any a priori way to detect how your program was started. The usual workaround is to configure the shortcut file to pass a parameter on the command line. Then, check for the existence of that parameter at run time. If you find it there, assume the program was started from a shortcut. The key to this approach is the fact that you can't include a parameter when double-clicking the EXE file in Explorer, so if you find a command-line parameter, you know the program wasn't started that way.
Upvotes: 0