2

My question clarified is, "What's different about running a command from within the registry at command line compared to running the same command from in a command line? Then how do I make it the same to work the way I want?"

Information about my program:
This is a ClickOnce application and from what I see there isn't a great way of getting the exact path of the exe instead of the appref-ms. So there is a caveat to my question this whole thing can be avoided if there was a way to find the exact path of the exe each time the program is deployed and I am able to edit the registry to point to said written down path.

I have this entry in HKEY_CLASSES_ROOT please see evidence below:

Picture of my custom registry entry for a Windows Context Item

So right clicking below should work everything is typed in right, but it doesn't work.

Picture of my error message from Windows after clicking my context menu item

So I figured maybe it didn't like my %APPDATA% which honestly should not matter and I got a new error message.

My new registry entry command of the context menu item

Still broke new message


Just so you know my program does work and it's doing something and pulling paths from the args passed to it.

This works for some reason unbeknownst to me

Thank you for reading my lengthy question.

IByrd
  • 177
  • 1
  • 13
  • I found out the difference. It is that the registry uses run... to open things. But even so it's saying path cannot be found for this run command "cmd.exe /K "%appdata%\Microsoft\Windows\Start Menu\Programs\Alliance Steel\Alliance Steel Shippers\Shipper Editor.appref-ms" "%1"" – IByrd Apr 29 '15 at 21:57
  • I figured it all out. In addition to it using run it will not expand the %appdata% so it did matter I had to create a foobar key that regedit won't allow normally using contextedit from pc mag because it has a gui... Made the REG_SZ a REG_EXPAND_SZ and %appdata% works. Will answer my own question soon with steps I took to get a ClickOnce application to read in command line arguments and run from a Windows Context Menu Item. – IByrd Apr 29 '15 at 22:13

1 Answers1

1

Here is how you set up what I have been trying to setup for a while now. This explanation is assuming you know exactly what you are trying to do.

Publishing A (Offline) ClickOnce Application With Command Line Args Ran From A Right Click Context Menu Item That You Can Deploy As Many Times As You Want Without Editing the Registry Each Time.

If you are doing an online one just use this CTRL+F and type in deadlydog it has two stellar links in that answer. That is much simpler then this below.

  1. Have a project that is published deployed on a file share using ClickOnce in Visual Studio project properties.
  2. Get this code. (If you need multiple args treat them all as one large string then split it)

    'VB.NET style code
    Dim activationData() As String = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData
    
    MsgBox(activationData(0)) 'Your big long argument before being split editted or modified.
    

Why I asked this question and my answer to it.

  1. Make a registry entry using ContextEdit as if you were making your very normal run of the mill context menu for your program. HOWEVER!!!! click the check box that says "expand environment variables".
  2. So the command that you type in should look like this.
    cmd.exe /C ""%InsertEnvironmentVariable%\Path\Name To\Your File.appref-ms" "%1""

It should work from that it was a ton of googling mostly because I have never done this and I give up easily on ideas. Also would like to comment on the information for command line and the registry is atrociously organized and abundant beyond belief.

Hope this helps someone trying to deploy a neat clickonce lightweight program that seems integrated like a normal program.

Community
  • 1
  • 1
IByrd
  • 177
  • 1
  • 13