Clone this wiki locally

Chocolatey Utility Functions aka Helpers Reference

Main Helpers

These helpers call other helpers and have error handling built in. When using just them, you don't need to put error handling in your chocolateyInstall.ps1 file. These helpers call down to the other helpers and encapsulate everything nicely so that it is possible to have one line chocolateyInstall.ps1 files.

Non-Administrator Safe Helpers

Some folks expressed a desire to have chocolatey not run as administrator to reach continuous integration and developers that are not administrators on their machines. Starting with chocolatey v0.9.8.3, this has been possible.

Install-ChocolateyExplorerMenuItem [src]
Creates a windows explorer context menu item that can be associated with a command

C:\PS>$sublimeDir=(Get-ChildItem$env:systemdrive\chocolatey\lib\sublimetext*| select $_.last)
C:\PS>$sublimeExe="$sublimeDir\tools\sublime_text.exe"
C:\PS>Install-ChocolateyExplorerMenuItem"sublime""Open with Sublime Text 2"$sublimeExe# This will create a context menu item in Windows Explorer when any file is right clicked. The menu item will appear with the text "Open with Sublime Text 2" and will invoke sublime text 2 when selected.

Install-ChocolateyFileAssociation [src]
Creates an association between a file extension and a executable

C:\PS>$sublimeDir=(Get-ChildItem$env:systemdrive\chocolatey\lib\sublimetext*| select $_.last)
C:\PS>$sublimeExe="$sublimeDir\tools\sublime_text.exe"
C:\PS>Install-ChocolateyFileAssociation".txt"$sublimeExe# This will create an association between Sublime Text 2 and all .txt files. Any .txt file opened will by default open with Sublime Text 2.

Install-ChocolateyShortcut [src]
This adds a shortcut, at the specified location, with the option to specify
a number of additional properties for the shortcut, such as Working Directory,
Arguments, Icon Location, and Description.

Install-ChocolateyShortcut-shortcutFilePath "C:\test.lnk"-targetPath "C:\test.exe"# This will create a new shortcut at the location of "C:\test.lnk" and link to the file located at "C:\text.exe"

Install-ChocolateyVsixPackage"MyPackage" http://visualstudiogallery.msdn.microsoft.com/ea3a37c9-1c76-4628-803e-b10a109e7943/file/73131/1/AutoWrockTestable.vsix
# This downloads the AutoWrockTestable VSIX from the Visual Studio Gallery and installs it to the latest version of VS.