26

I have a Clickonce application that is launched from the start menu (local). I would like to be able to specify a parameter so that the application can load certain data. The application lives on a fileshare and will be launched using the URL only once (like described here on MSDN). This implies that the method describe in this link will not work; users will be launching the application using an .appref-ms shortcut in the Start Menu.

I haven't been able to find a solution. Is it possible to somehow pass a parameter into the click once application? If so, how? If not, what are some alternatives?

Szymon Rozga
  • 17,971
  • 7
  • 53
  • 66
  • I have a feeling this may get closed due to your other question but what are you trying to solve with arguments to your app? – Austin Salonen Jan 09 '09 at 21:26

4 Answers4

18

Since you get to the deployment manifest via a Url, you can pass all of that information via the query string (e.g. http://clickonce.example.com/shell.application?p1=this&p2=that)

I was going to type out the steps, then googled and found this blog that basically lists out all the steps. I've done something similar in one instance with no issues. The only slightly difficult thing is that you have to re-mage after setting things up, but if you got it to deploy in the first place, you already know how to set things up.

Good luck!

Sam Axe
  • 33,313
  • 9
  • 55
  • 89
joshua.ewer
  • 3,944
  • 3
  • 25
  • 35
  • Even though this isn't exactly what I'd like, I think I can make this work. – Szymon Rozga Mar 19 '09 at 13:07
  • 1
    I have the same feeling every time I use ClickOnce. It's so simple to use, but only if you're doing the handful of things it does well. So, it's just a matter of making sure the tool fits your circumstances. If you have simple deployment needs, ClickOnce is one of the easiest tools I've ever used – joshua.ewer Mar 19 '09 at 15:32
  • I tried that blog's solution, but in Windows Explorer, when I Right-Clicked on my "(My App Name).application" File, selected "Created Shortcut", Right-Clicked on that Shortcut File, selected "Properties", changed the "Target" to the above format, selected "Apply" (or "OK") and got a pop-up Window with the message: "Problem with Shortcut The name 'http://(My ClickOnce Publishing Folder Location)/(My App Name).application' specified in the Target box is not valid. Make sure the path and file name are correct.". – Tom Jul 31 '19 at 17:42
6

All of the answers here only apply to Online ClickOnce applications. This MSDN Forum post and this blog post discuss some ways to do it for Offline ClickOnce applications.

deadlydog
  • 22,611
  • 14
  • 112
  • 118
3

Perhaps you could pass a parameter on the URL the first time, and have the app take notice of that, and write the parameters to a config file, or environment variables or somesuch.

On subsequent runs, load from the config file

Orion Edwards
  • 121,657
  • 64
  • 239
  • 328
0

You pass the parameters as a query string and use HttpUtility.ParseQueryString, as discussed in this MSDN article.

Magnus Johansson
  • 28,010
  • 19
  • 106
  • 164