none
Registering ClickOnce App as handler for a custom URL protocol RRS feed

  • Question

  • I am trying to register my ClickOnce application as the handler for a custom URL protocol.  I tried to follow the instructions on this page to add a subkey to the registry under HKEY_CLASSES_ROOT, but at run time, the My.Computer.Registry.ClassesRoot.CreateSubKey method throws error "Access to the registry key 'HKEY_CLASSES_ROOT\TestKey' is denied."

    Following the instructions from Paul Ishak on this page, I next tried to go into app.manifest to change <requestedExecutionLevel  level="asInvoker" uiAccess="false" /> to <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />. However after this change I get a compile time error: "ClickOnce does not support the request execution level 'requireAdministrator'"

    I am not sure where to go from here: how can I register my ClickOnce application as the handler for a custom URL protocol?  How can I add this protocol under HKEY_CLASSES_ROOT?

    Thank you,

    -Patrick

    PS. The app is run from the user's desktop, not a website

    Saturday, August 11, 2012 3:44 PM

Answers

All replies

  • Hi Patrick,

    Due to the risk of exposing applications to security elevation attacks, ClickOnce applications cannot request permission elevation if UAC is enabled for the client. Any ClickOnce application that attempts to set its requestedExecutionLevel attribute to requireAdministrator or highestAvailable will not install on Windows Vista. For more details, see http://msdn.microsoft.com/en-us/library/ms228996.aspx

    According to the MSDN document, class registration and file name extension information is stored under both the HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER keys. The HKEY_LOCAL_MACHINE\Software\Classes key contains default settings that can apply to all users on the local computer. The HKEY_CURRENT_USER\Software\Classes key contains settings that apply only to the interactive user. You might try write the HKEY_CURRENT_USER instead.

    Another way is starting the application as a local application with administrator permission, see http://antscode.blogspot.com/2011/02/running-clickonce-application-as.html. However, the re-launch application is no longer a ClickOnce application but a local application.

    If none of them works as expected and you are developing an application that requires administrator permissions for the entire lifetime of the application, you should consider deploying the application by using Windows Installer (MSI) technology instead.

    For more details, see 

    http://msdn.microsoft.com/en-us/library/ms228996.aspx

    http://msdn.microsoft.com/en-us/library/bb383802.aspx

    http://social.msdn.microsoft.com/Forums/zh/winformssetup/thread/ff9c0adf-3895-4ca2-aee0-95113ae4ea45

    Best Regards,


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, August 14, 2012 7:17 AM
    Moderator
  • Bob,

    Thanks for the reply.  I will try writing the info under HKEY_CURRENT_USER

    Wednesday, August 22, 2012 10:18 PM
  • Hey Bob,

    It took me 2 years to come back to this problem. Your advice was spot on as I was able to implement it with some success yesterday. Thanks so much for taking the time to write.

    By adding a subkey to HKEY_CURRENT_USER\SOFTWARE\CLASSES, I was able to register a URL protocol. A link with the registered protocol correctly launches the application, however the command line parameters are NOT passed to the App.  Looking around I learned that this has something to do with security, so I made sure that "This is a full trust application" is selected in Project Properties -> Security Tab.  That made no difference however: command line parameters are not passed to the app.

    Thanks again for your help,

    -Patrick

    Thursday, September 4, 2014 8:27 AM