BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
kyle_lamson
Community Trekker

Clickonce Application

Does anyone have the syntax needed to run a clickonce application. I've tried

RunProgram(executable("clickonce application"));

Which I figured wouldn't work. Are there any other options?

0 Kudos
4 REPLIES 4
txnelson
Super User

Re: Clickonce Application

The following might be of use, it was taken from:

http://www.brad-smith.info/blog/archives/535

Starting ClickOnce applications

Unlike normal executables, applications deployed using ClickOnce are started using a bootstrapper (which is normally handled by the shell). This includes applications written in Windows Forms, WPF or Silverlight. Shortcuts to ClickOnce apps have the extension .appref-ms (rather than .lnk for regular shortcuts), and these files are not recognised by the start command (as in the previous example).

Thankfully, they can be run using the following syntax:

1rundll32.exe dfshim.dll,ShOpenVerbShortcut [path to appref-ms file]

Where [path to appref-ms file] is the full path to the ClickOnce shortcut file. The path may include environment variables such as %USERPROFILE% if, for example, you want to point to a shortcut on the user’s desktop.

How does this work?

  • The rundll32 command executes a function in a Win32 DLL as if it were an executable file. You might want to use this when you have a function which is predominantly called from code (but still operates independently), if you want to avoid creating many executables when a single DLL will suffice, or to deliberately obfuscate a command that users are not intended to start.
  • dfshim.dll is responsible for much of the functionality in ClickOnce; it contains functions to install, remove, start and update applications, and is distributed as part of the .NET Framework.
  • The name of the function we want is ShOpenVerbShortcut, which is the same function that the windows shell uses to run .appref-ms shortcut files. You simply pass a path to the function and it takes care of the rest.
Jim
0 Kudos
pzang
Community Trekker

Re: Clickonce Application

The rundll32 method works by itself but I cannot find a way to pass parameter to the .appref-ms.  I eventually solved the problem by using the following:

 

 

RunProgram(
	executable( "cmd.exe" ),
	options(
		{"/c",
		"\!"PathToShortcut.appref-ms\!"",
		"parameter"}
	),
	readfunction( "text" )
);

I added the double quotes to my PathToShortcut.appref-ms because it has spaces.

 

0 Kudos
pzang
Community Trekker

Re: Clickonce Application

Using the rundll32 method, the parameter can be passed to the clickonce program like below:

RunProgram(
	executable( "rundll32.exe" ),
	options( {"dfshim.dll,ShOpenVerbShortcut","PathToShortcut.appref-ms|parameter"} ), 
	readfunction( "text" )
);

 

0 Kudos
kyle_lamson
Community Trekker

Re: Clickonce Application

I figured it out after enough poking around.

web("clickonce application.appref-ms");