choco icon indicating copy to clipboard operation
choco copied to clipboard

choco-url to easily install a package via one click like with AptProtocol (apt://)

Open DJCrashdummy opened this issue 7 years ago • 24 comments

i'm not sure where to post this, so please bear with me if this is the wrong place!


i like AptProtocol for its easiness to suggest installation of a package either on a website, in an email or in any other document via one click (resp. a second one to confirm it's installation).

IMHO a choco-protocol - or maybe also work with apt:// - would be a nice tool to provide the simplest method possible to install packages from chocolatey. e.g. chocolateygui is nice but i rather use https://chocolatey.org/packages to browse the packages because it provides more information. after that i have open powershell and type the install-command (which is ok), but noobs have to open chocolateygui, wait for a refresh and look for the correct package again to install it. instead of this bunch of additional steps and time a little "install now"-button at the homepage would ease the things a lot.

DJCrashdummy avatar Nov 19 '18 07:11 DJCrashdummy

I like this idea, like you I actually find the packages I want on the webpage first (easier than searching through the CLI IMO).

So having this would definitely make it easier. Seems to be pretty easy to set up as well, changing a few registry settings to pass the correct arguments to the client and updating the website to have a link with the correct protocol.

AdmiringWorm avatar Nov 19 '18 15:11 AdmiringWorm

@AdmiringWorm @DJCrashdummy if I have understood this correctly, we would need the ability to pass a navigation parameter into Chocolatey GUI to directly navigate to a Package Details page. Or have I misunderstood this?

gep13 avatar Nov 19 '18 16:11 gep13

@AdmiringWorm which registry keys are you referring to? Do you have a link to what you are describing?

gep13 avatar Nov 19 '18 16:11 gep13

if I have understood this correctly, we would need the ability to pass a navigation parameter into Chocolatey GUI to directly navigate to a Package Details page. Or have I misunderstood this?

No, to the CLI itself. And not to navigate, but to actually install (unless I misunderstood it myself).

@AdmiringWorm which registry keys are you referring to? Do you have a link to what you are describing?

Something along the line of:

[HKEY_CLASSES_ROOT\apt]
@="URL:Apt Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\apt\shell]
[HKEY_CLASSES_ROOT\apt\shell\open]
[HKEY_CLASSES_ROOT\apt\shell\open\command]
@="\"choco\" install \"%1\""

^^ may need full path to choco.exe I believe the above would allow for urls like apt://git (for installing git) It may be possible for something along the lines of using:

[HKEY_CLASSES_ROOT\apt]
@="URL:Apt Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\apt\shell]
[HKEY_CLASSES_ROOT\apt\shell\open]
[HKEY_CLASSES_ROOT\apt\shell\open\command]
@="\"choco\" %1 \"%2\""

To allow for urls like apt://install/git or apt://upgrade/git (but this is something I have no idea if it works)

source was found here: https://support.shotgunsoftware.com/hc/en-us/articles/219031308-Launching-applications-using-custom-browser-protocols

NOTE: I have not yet tested this myself, but have seen something similar being used in the past.

AdmiringWorm avatar Nov 19 '18 16:11 AdmiringWorm

Could this be accomplished as well via a browser plugin to open nuspkg files using "choco install" upon download?

bcurran3 avatar Nov 19 '18 19:11 bcurran3

@bcurran3 said: Could this be accomplished as well via a browser plugin to open nuspkg files using "choco install" upon download?

I honestly don't know, but it probably could.

~Anyways, I tested out the registry changes, and it does indeed work. Unfortunately due to the nature of chocolatey where it needs to run as an admin, this is something I haven't yet been able to do 😢~

EDIT: Scratch that, support for apt:// urls would still need to be baked into choco, as the whole url is passed to it 😢

AdmiringWorm avatar Nov 19 '18 20:11 AdmiringWorm

Setting cinst.exe as "Run this program as an administrator"

and

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\nupkg_auto_file]

[HKEY_CLASSES_ROOT\nupkg_auto_file\shell]

[HKEY_CLASSES_ROOT\nupkg_auto_file\shell\open]

[HKEY_CLASSES_ROOT\nupkg_auto_file\shell\open\command] @=""C:\ProgramData\chocolatey\bin\cinst.exe" "%1""

...allows double clicking on .nupkg files to autorun/autoinstall

Maybe there's something to run with here...

bcurran3 avatar Nov 19 '18 21:11 bcurran3

if I have understood this correctly, we would need the ability to pass a navigation parameter into Chocolatey GUI to directly navigate to a Package Details page. Or have I misunderstood this?

No, to the CLI itself. And not to navigate, but to actually install (unless I misunderstood it myself).

@gep13 and @AdmiringWorm yes and no: for sure the execution is done at choco.exe but i highly recommend to somehow ask for confirmation before doing so, because hardly any noob looks at the URL behind a link before he clicks it. - doing this in the shell will scare off noobs, so some kind of GUI should be involved.

at debian/ubuntu/etc. apturl is a separate package and it doesn't open any package manager, but a small window to ask for a confirmation: apturl

an other not so advanced approach would be to open the existing package details page of chocolateygui... but still an improvement compared to now. - and what the URL does/opens can still be changed/improved later.

DJCrashdummy avatar Nov 21 '18 14:11 DJCrashdummy

@DJCrashdummy I don't know about other browsers, but I do know that chrome asks for confirmation to run the executable associated with the custom protocol.

IMO, this should be enough (if other browsers behave the same)

AdmiringWorm avatar Nov 21 '18 16:11 AdmiringWorm

I can't say I quite have my head wrapped around the apt "protocol" portion, but I will say that the intent is completely doable. I've already done a proof of concept and created a scope of work for a package that I will create that will allow you to click download a package from chocolatey.org (or elsewhere) and auto-install the package from Chrome.

A small step towards making chocolatey.org pseudo-similar to ninite.com...

SIDENOTE: http://appnr.com/ is pretty damn cool, never saw that site before.

As for implementing it natively in Chocolatey, I think the challenge is adding the support for a "choco://" protocol to all browsers. It would require constantly checking for and updating various browser configs to support it. (i.e. When Chocolatey is initially installed it might not find Chrome, FireFox, or Opera installed because Chocolatey is going to be used to install them. So Chocolatey would then need to keep looking for browsers to inject support for a "choco://" protocol. Seems very cumbersome.) The key thing to take away here is that browser support is needed.

Non-native support via plug-ins for browsers would probably be the best route to go.

Looking at the apt:// method using aptlinex and apturl support programs as an example, a small executable could be used to approve/cancel installation of a package would be a good addition.

My plan to make this intent possible:

  • Set registry to open .nupkg files with cinst.exe
  • Set cinst.exe to require run as administer
  • Set Chrome to auto-open .nupkg files

Not really very hard!

(Then look at implementing via FireFox.)

I still think this is best done via browser extensions, but I've never written one. Any volunteers? There's probably one out there that I could copy, paste, and modify... :)

bcurran3 avatar Nov 21 '18 22:11 bcurran3

maybe it is useful... a wiki-link of apturl with integration steps into some browsers: https://help.ubuntu.com//community/AptURL

another wiki-link with integration steps (translated from german): https://translate.google.com/translate?sl=de&tl=en&js=y&prev=_t&hl=de&ie=UTF-8&u=https%3A%2F%2Fwiki.ubuntuusers.de%2Fapturl%2F%23Integration-in-andere-Browser&edit-text=&act=url

DJCrashdummy avatar Nov 22 '18 00:11 DJCrashdummy

In the spirit of the original request... And dedicated to @DJCrashdummy.

I present to you: https://chocolatey.org/packages/choco-install-packages-from-web-winconfig

Maybe @AdmiringWorm will find it useful too!

bcurran3 avatar Nov 25 '18 01:11 bcurran3

@DJCrashdummy - your original dream is becoming a reality...

~~https://chocolatey.org/packages/chocoprotocolstub~~

EDIT: Redone as https://chocolatey.org/packages/choco-protocol-support using Sudo and a batch file instead of a proprietary "assembly" that I wrote.

bcurran3 avatar Nov 26 '18 01:11 bcurran3


The following is my personal re-write of the enhancement request:


ENHANCEMENT REQUEST: Add support for custom choco:// protocol

Chocolatey - like yum or apt-get, but for Windows

Requesting Chocolatey feature duplication of AptURL/Apt Protocol. e.g. chocoURL/choco Protocol

IMPLEMENTATION:

  • Upon installation of Chocolatey a custom choco Protocol would be configured in the Window's registry.
  • choco.exe input to accept chocoURL (choco://packagename) as an input OR creation of a choco protocol handler/stub (SUGGEST: cprot.exe)
  • All package pages updated on chocolatey.org :-) and new corporate intranet web pages with click to install corporate approved software.

CONSIDERATIONS:

  • When browsers run the program associated with the protocol, the configured program will run with typically non-elevated user permissions. This results in only a handful of packages that could actually be installed. Thus, there needs be some way to elevate to admin privileges for real world package installation. To solve this, choco.exe could be passed a new argument that tells it to re-run itself with elevated privileges. Using a pre-processing choco protocol handler/stub with the internal manifest set to run as admin might be a better way of doing this. Going the choco protocol handler/stub route, no modification to choco.exe would be necessary. The choco protocol would be configured to run the choco protocol handler/stub. The chocoURL would be parsed by the choco protocol handler/stub (running with admin privs) and would then run choco.exe to install the package normally.
  • The choco protocol handler/stub is probably best implemented using a Windows GUI program that could prompt for package installation and, separately, privilege elevation confirmation as well as an option to save these confirmations as defaults.

RESULT: Chocolatey becomes much more user friendly for the browser-inclined-CLI-neophyte Average Joe. Chocolateasy! (future tm)

PROOF OF CONCEPT: Proof of concept implemented using a (CLI) handler/stub program I wrote to process the chocoURL and then execute cinst.exe (registry manipulated to run as admin): ~~https://chocolatey.org/packages/chocoprotocolstub~~

EDIT: Redone as https://chocolatey.org/packages/choco-protocol-support using Sudo and a batch file instead of a proprietary "assembly."


RELATED/NOT RELATED BUT SIMILAR: Similar functionality available now. https://chocolatey.org/packages/choco-install-packages-from-web-winconfig

bcurran3 avatar Nov 27 '18 17:11 bcurran3

I wanted to say this is a duplicate, but I don't see the original (perhaps it is in the old chocolatey/chocolatey repository).

ferventcoder avatar Nov 27 '18 18:11 ferventcoder

beforehand: sorry for being silent so long, but i was busy at work the last months and had no time to fiddle around with a windows machine.


choco-protocol-support

thank you very much @bcurran3! :+1: it works like a charm (even with edge - i've tested it because it is nowhere mentioned). :clap: but one interesting thing i noticed: (whether it is installed or not) if i try to view the details-page in the Chocolatey GUI it crushes. - this is the only package with this issue so i guess it must have to do with it and/or its description resp. rendering of them in the Chocolatey GUI.

choco-install-packages-from-web-winconfig

unfortunately it does not work for me. :slightly_frowning_face: i'm pretty sure because cinst.exe is not executed as admin (although it is explained otherwise in the details). :confused:

PS @bcurran3: may i suggest to strike through all mentions and links of chocoprotocolstub since it was rejected... or is there a reason why it may still be interesting to try?

DJCrashdummy avatar Feb 03 '19 10:02 DJCrashdummy

thank you very much @bcurran3! 👍 it works like a charm

(even with edge - i've tested it because it is nowhere mentioned). 👏

I did some QUICK testing with Edge and it looked like it sandboxed it so quit really fast and moved on. :) (I don't use Edge.) Thanks for letting us (me) know it works with Edge!

but one interesting thing i noticed: (whether it is installed or not) if i try to view the details-page in the Chocolatey GUI it crushes. - this is the only package with this issue so i guess it must have to do with it and/or its description resp. rendering of them in the Chocolatey GUI.

Very weird. Not sure what's causing that. I thought maybe the choco protocol URL was crashing it but it displays it fine in other packages. I opened https://github.com/chocolatey/ChocolateyGUI/issues/649 for @gep13 to check it out.

choco-install-packages-from-web-winconfig unfortunately it does not work for me. 🙁 i'm pretty sure because cinst.exe is not executed as admin (although it is explained otherwise in the details). 😕

I'd suggest to remove and reinstall. There's also a possibility that it might not work if you already had .nupkg associated with a program under your USER profile. BUT... I'm putting out a v0.0.2 soon reworked to run a batchfile and use Sudo to keep it inline with it's sister package choco-protocol-support. That way it doesn't need to change the cinst.exe compatibility layer/manifest

PS @bcurran3: may i suggest to strike through all mentions and links of chocoprotocolstub since it was rejected... or is there a reason why it may still be interesting to try?

Done. I didn't at first because it works, and works slightly better and faster than choco-protocol-support and people can still use it if they wanted. It was rejected not because it didn't work or work well, @ferventcoder didn't

"...want chocolatey.org to be the first validation in the "web of trust" for assemblies that are placed onto chocolatey.org. Rather, that this validation is asserted elsewhere. What it comes down to is that although we know you as a maintainer and trust the work that you have done in this area, we can't independently verify what is going on with the assembly that you are adding into the package."

So basically it wasn't allowed because they didn't have the source. So I re-imagined it into a batch file that anyone could see what it does.

I have gone back and struck out the references to avoid confusion and edited in a comment that it was replaced/superceded by choco-protocol-support which does the same thing and is "blessed."

bcurran3 avatar Feb 19 '19 22:02 bcurran3

(I don't use Edge.) Thanks for letting us (me) know it works with Edge!

me neither, :wink: but i didn't have something else on a virgin test machine. - that was my intention.

I thought maybe the choco protocol URL was crashing it but it displays it fine in other packages.

this was also my first thought, but it is definitely not the case. - yes, very weird.

choco-install-packages-from-web-winconfig I'd suggest to remove and reinstall. [...] I'm putting out a v0.0.2 soon reworked [...]

already tried this and now once again, but no change. i just wanted to let you know... - (since i hardly use windows) no problem, i'll "wait" for v0.0.2.

DJCrashdummy avatar Feb 25 '19 13:02 DJCrashdummy

There is another option that might be easier:

Check out the install button in this link: https://marketplace.visualstudio.com/items?itemName=auchenberg.vscode-browser-preview It is: vscode:extension/auchenberg.vscode-browser-preview

so, the format for choco would be something like this: choco:action/package

This is the documentation for it: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/launch-app-with-uri

It is the same idea as the mailto: link.

Omzig avatar Mar 12 '19 21:03 Omzig

although not suggested at my initial post... if not using apt:// but "creating" an own choco:// protocol, supporting chocolaty parameters as discussed at https://github.com/bcurran3/ChocolateyPackages/issues/138 would make sense.

DJCrashdummy avatar Apr 26 '20 10:04 DJCrashdummy

After thinking about this some and some discussion with @gep13, there are a couple of points about how this should be implemented:

  • Instead of passing the URI to choco install, a new command like choco uri should be created. This is for security reasons, so someone can't do something like choco install choco://googlechrome --yes --source=https://malware/api. Having a separate command should allow much more secure parsing.
  • It would be good to have a versioned api, so any future updates/changes can be made, and we are not locked into one format. E.g. start off with choco://v1/<package to install>, then later add more features like choco:///v2/<install|upgrade|uninstall>/<package>/<version>?parameter=param or whatever.
  • If specifying a source is allowed should be thought through carefully.

TheCakeIsNaOH avatar Dec 03 '21 17:12 TheCakeIsNaOH

This actually appears to be a duplicate of #684, although most of the discussion is happening in this issue.

TheCakeIsNaOH avatar Jan 06 '22 17:01 TheCakeIsNaOH

This issue was added to the 1.0.0 milestone, however, after discussion, we are not going to include this in the 1.0.0 release, but hopefully quite quickly after the 1.0.0 release.

gep13 avatar Feb 04 '22 09:02 gep13

Hey, this is a great idea!

greetings from 2025! Are there any blockers or major concerns before moving forward?

fdcastel avatar May 31 '25 06:05 fdcastel

can we get this moved out of the backlog and into the next to be worked on pile?

Omzig avatar Jul 09 '25 15:07 Omzig

If you have a look at the top issues in the repository, this is not ranked highly in priority for users.

pauby avatar Jul 09 '25 17:07 pauby

If i understand this correctly, we need to make the 4 thumbs up at the top go over 18, so it will surface in that list :)

Omzig avatar Jul 09 '25 19:07 Omzig

i'm not sure where to post this, so please bear with me if this is the wrong place!

i like AptProtocol for its easiness to suggest installation of a package either on a website, in an email or in any other document via one click (resp. a second one to confirm it's installation).

IMHO a choco-protocol - or maybe also work with apt:// - would be a nice tool to provide the simplest method possible to install packages from chocolatey. e.g. chocolateygui is nice but i rather use https://chocolatey.org/packages to browse the packages because it provides more information. after that i have open powershell and type the install-command (which is ok), but noobs have to open chocolateygui, wait for a refresh and look for the correct package again to install it. instead of this bunch of additional steps and time a little "install now"-button at the homepage would ease the things a lot.

this the first post please, we need it to go over 18

Omzig avatar Jul 09 '25 19:07 Omzig

woohoo we are up to 14 now, only a few more now ;)

Omzig avatar Jul 11 '25 15:07 Omzig

@pauby

If you have a look at the top issues in the repository, this is not ranked highly in priority for users.

I just realized that ALL the "top issues" date back to before 2019.

This isn't particularly inspiring, to put it mildly.

fdcastel avatar Jul 18 '25 03:07 fdcastel