How can I tell if a .NET application was launched using a shortcut?

Is it possible to tell if your current .Net application was launched with a Clickonce app shortcut or link (* .appref-ms)? If so, how?

Some background: I have a problem with Microsoft Clickonce where I am unable to pass command line arguments to the application. It looks like this is how technology works by design. I've been looking into various ways to pass this parameter; one of them was to have a set of different combinations of Clickonce menu buttons.

0


source to share


2 answers


Try checking the ApplicationDeployment.IsNetworkDeployed property . I know this will be true if it is a ClickOnce application, but I'm not sure if it will be false in your situation.



+1


source


I'm not sure what the "application link file" is; do you mean how to double click the EXE file in explorer or run the file from the command line?



There is no a priori way to determine how your program was started. A common workaround is to configure the shortcut file to pass the parameter on the command line. Then check for the presence of this parameter at runtime. If you find it, assume that the program was launched from a shortcut. The key to this approach is the fact that you cannot enable the option when you double-click the EXE file in explorer, so if you find the command line option, you know the program didn't start that way.

0


source







All Articles