I'm trying to develop a script to automate the installation of some programs and also the development environment. So I thought Chocolatey could help me with that.
How can I create a script to be run in the power shell to install chooclaty and then other applications?
It would be a script to run something like this:
# Install Chocolatey
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
#After finish Chocolatey, run the commands:
# install apps
choco install vscode, git, nvm --force -n
# using nvm to install node version
nvm install v14.17.1
nvm use 14.17.1
# install yarn
npm install --global yarn
#install expo
npm install --global expo
Any idea how to do this? I would also improve the script to clone the repository, install dependencies with yarn, etc.
CodePudding user response:
You could launch your later commands in a new powershell instance like this:
start powershell {npm install --global yarn; npm install --global expo}
For reference, you can find multiple different ways to do this with different options, depending on your future requirements, here.