Jump to content
Testing123

Deploying Chocolatey

Recommended Posts

Posted (edited)

Hey everyone,

I'm pretty new to Automate, and I know a lot of you use Chocolatey in conjunction with Automate. But I'm kind of stumped as to how to deploy Chocolatey via script.

Taking, for example, the cmd.exe installer on https://chocolatey.org/install and packaging it in an Automate script, it runs and seems to install Chocolatey as it should, but fails to add the path variable which means it can't subsequently be called with its alias in future scripts.

I think this is because I'm failing to run the command under the right context.

Running as 'Shell' presumably runs as the system account, so that doesn't work.

I'd assume that 'Shell as admin' would work as this uses the site's domain admin credentials, but no joy there either.

I'm positive I'm missing something really dumb, and whatever the answer is will help with building Automate scripting in the future.

Cheers!

 

quick edit: I did search but didn't find the answer, which makes me think this is forehead-slapping levels of easy, but I just don't seem able to crack it.

edit 2: I logged onto a machine, install chocolatey under the localadmin user. Choco /? returns okay for both the regular domain user and the local admin, but trying in command prompt in Automate still doesn't work.

Additionally, installing in the same way using NinjaRMM (running script as system user) works fine - the user, scripts in Ninja, and Ninja's command prompt can also run choco /? - I really can't work out why in Automate running as Shell or Shell as admin doesn't work (neither the user or Automate's scripting/command prompt can call choco). So whatever it is, it's an Automate lesson I need to learn.

Edited by Testing123

Share this post


Link to post
Share on other sites

Run this as a shell command in your script (do not use Shell as Admin, as any "as Admin" command runs without elevated permissions if UAC is enabled).

@powershell -NoProfile -ExecutionPolicy bypass -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×