Chocolatey

A silent installer for Chocolately (https://chocolatey.org), which in turn does silent Windows software installs.

This downloads the install.ps1 script, which will download and install chocolatey to %programdata%\chocolatey.

Once this is installed, you can use commands like "choco install 7zip -y" to install software automatically. This can be useful to save having to update WPKG packages for common tools, as chocolatey has a central repository.

An example of how packages might be installed using WPKG to trigger chocolatey installs is given below.

<?xml version="1.0" encoding="UTF-8"?>

<packages:packages xmlns:packages="http://www.wpkg.org/packages"
	xmlns:wpkg="http://www.wpkg.org/wpkg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.wpkg.org/packages ../xsd/packages.xsd">

 	<package
                id="chocolatey"
                name="Chocolatey"
                revision="1.%version%"
                reboot="false"
                priority="1">
		
		<variable name="version" value="0.10.5.0" />

		<check type="file" condition="exists" path='%programdata%\chocolatey\bin\chocolatey.exe' value="%version%" />
		
		<variable name="installerPath" value="chocolatey\install.ps1"/>
		<variable name="installerURL" value="https://chocolatey.org/install.ps1" />

		<!-- standard variables - usually in config.xml -->
		<variable name="SOFTWARE" value="software" 		/>	
		<variable name="DOWNLOADERPATH" value="tools\downloader\downloader.cmd"  />  
		<!-- conditional download -->
		<install cmd='"%DOWNLOADERPATH%" "%installerURL%"	"%software%\%installerPath%"  >NUL'>
			<condition><check type="logical" condition="not"><check type="file" condition="exists" path="%SOFTWARE%\%installerPath%" /></check></condition>
		</install>		
		
		<install cmd='powershell "%SOFTWARE%\%installerPath%"'  /> 
		
		<upgrade include="install" />
		<remove cmd='cmd /c rmdir /s /q "%programdata%\chocolatey\"' /> 

  	</package>
	
	<package
                id="chocobasic"
                name="Basic packages (using Chocolatey)"
                revision="1"
                reboot="false"
                priority="1">

		<depends package-id="chocolatey" /> 
	
		<!-- See https://chocolatey.org/packages . Can use more than one:
			<variable name="PKGNAMES" value="vlc firefox nssm notepadplusplus git 7zip" />
		-->	
		<variable name="PKGNAMES" value="classic-shell googlechrome notepadplusplus" />
		
		<!-- check for a version of each package -->
		<check path='Classic Shell' 	value='4.3.0' 			type='uninstall' condition='versiongreaterorequal' />
		<check path='Google Chrome' 	value='61.0.3163.100' 	type='uninstall' condition='versiongreaterorequal' />
		<check path='Notepad\+\+.*' 	value='7.5.1' 			type='uninstall' condition='versiongreaterorequal' />
	        <!--
		Or could possibly use choco list in a .cmd file like this, though harder to catch versiongreaterorequal:
			choco list - -localonly | findstr /ib /c:%1
			exit %ERRORLEVEL%
		<check type="execute" path='chocotest.cmd "7zip "' condition="exitcodeequalto" value="0"/>		
		-->
		
		<!-- "choco upgrade" command installs or upgrades as appropriate. -->
		<install cmd='%COMSPEC% /v /c set ChocolateyInstall=%programdata%\chocolatey&amp;&amp; %programdata%\chocolatey\choco upgrade %PKGNAMES% -y &gt;"%programdata%\chocolatey\logs\wpkgchocoinstall.log"'  /> 
		<upgrade include="install" />
		<remove  cmd='%COMSPEC% /v /c set ChocolateyInstall=%programdata%\chocolatey&amp;&amp; %programdata%\chocolatey\choco uninstall %PKGNAMES% -y &gt;"%programdata%\chocolatey\logs\wpkgchocoinstall.log"'/>
		
		<!-- 
		Useful to pipe chocolatey output to log file: e.g. &gt;"%programdata%\chocolatey\logs\wpkgchocoinstall.log"
		See also C:\ProgramData\chocolatey\logs\chocolatey.log
		-->
  	</package>		

</packages:packages>