Chocolatey app installs fail when scripted, succeed when run in PS manually.

I have a script intended to install a standard complement of software via Chocolatey with the “choco install ($APP)” command. When I run this script, it seems that the first one or two packages download and install normally but none of the others do. Re-running the script yields similar results, with the next couple in line getting installed. I added logging to the command and checked the log file, and saw that it contained two successful installs followed by a long chain of “The package was not found with the source(s) listed” errors.

cutepdf not installed. The package was not found with the source(s) listed.
Source(s): ‘
NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn’t specify --pre,
the package may not be found.

Now, when I copy the command from my script and run it in PowerShell manually, the packages ALL download and install without issue (except those already installed, which are skipped per Chocolatey’s design). Has anyone else run into this and can anyone offer advice on how to fix it?

Hi @shnladd
Did you use the script listed below to run the ‘Chocolatey installations’? Or is it a custom script that you made yourself?

It isn’t the exact one you listed, but it was created by ITarian’s script team. Here’s the contents of the script:

ps_command=r'choco install 7zip.install firefox filezilla megasync kitty notepadplusplus.install veracrypt wiztree sumatrapdf.install cutepdf terminals teamviewer vlc foobar2000 sysinternals ccleaner greenshot f.lux.install wudt rufus --force --ignore-checksum > C:\chocoscriptinstall.txt'

import subprocess
import ctypes

class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirect ion
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirecti on
def __enter__(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:

with disable_file_system_redirection():
process=subprocess.Popen('powershell "%s"'%ps_command, shell=True, stdout=subprocess.PIPE)
if ret==0:
if result[0]:
print result[0].strip()
print None

print '%s
%s'%(str(ret), str(result[1]))