Is there any command to run a installed package with chocolatey?
Something like
choco run console2
Is there any command to run a installed package with chocolatey?
Something like
choco run console2
No, there is no command like that.
There is currently no way for Chocolatey to know how to invoke software or applications from a package. There is no property stored within packages to define this, nor is there a command available to do so. Chocolatey is a package manager, and a package is not actually just software.
Chocolatey packages don't actually even need to contain any sort of application.
The way to run software that has been installed (or deployed/dropped) by a package will vary by package, and by any installers contained within.
You can imagine that a CLI application that has simply been unzipped and shimmed (or otherwise added to PATH) will be available on the CLI (e.g. the emacs
package results in emacs.exe
being available), but you would just run that program - not invoke it via Chocolatey.
Similarly, an installed application will likely end up with shortcuts available (or not, depending on the installer and package logic).
Place the chocolatey bin folder on your PATH or if you don't want to do that then use the code below.
This code isn't foolproof but it would work in many cases to run a program in the choco bin folder or display the folder if no args. Place the code below in choco-run.bat and put that file in your PATH. I made use of the code here for the loop.
rem @echo off
rem rem Usage: choco-run commmand args
rem rem choco-run (display choco bin folder)
set choco_bin=C:\ProgramData\chocolatey\bin
set arg1=%1
if /i "%arg1%"=="" (
dir/w %choco_bin%
goto:eof
)
set rest=
shift
:loop
if "%1"=="" goto:loop_end
set rest=%rest% %1
shift
goto:loop
:loop_end
%choco_bin%\%arg1% %rest%