Skip to content

Instantly share code, notes, and snippets.

@solodyagin
Last active January 27, 2023 09:33
Show Gist options
  • Save solodyagin/4125f833910ce0d1c82f3ad4fb0c8120 to your computer and use it in GitHub Desktop.
Save solodyagin/4125f833910ce0d1c82f3ad4fb0c8120 to your computer and use it in GitHub Desktop.
(Chocolatey) Automatic installation script of programs
@echo off
net file 1>nul 2>nul
if "%errorlevel%" == "0" (goto admin)
:elevate
echo strArgs = "" > "%Temp%\elevate.vbs"
for %%f in (%*) do echo strArgs = strArgs ^& ^" ^" ^& Chr^(34^) ^& ^"%%~f^" ^& Chr^(34^) >> "%Temp%\elevate.vbs"
echo strParams = "/c " ^& Chr^(34^) ^& ^"%~s0^" ^& Chr^(34^) >> "%Temp%\elevate.vbs"
echo If strArgs ^<^> ^"^" Then >> "%Temp%\elevate.vbs"
echo strParams = strParams ^& ^" ^" ^& Chr(34) ^& strArgs ^& Chr(34) >> "%Temp%\elevate.vbs"
echo End If >> "%Temp%\elevate.vbs"
echo Set UAC = CreateObject^("Shell.Application"^) >> "%Temp%\elevate.vbs"
echo UAC.ShellExecute "cmd.exe", strParams, "", "runas", 1 >> "%Temp%\elevate.vbs"
"%Temp%\elevate.vbs"
del "%Temp%\elevate.vbs"
exit /B
:admin
rem Install Chocolatey
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
rem Microsoft Visual C++ 2005 SP1 Redistributable ( https://chocolatey.org/packages/vcredist2005 )
rem choco install -y vcredist2005
rem Microsoft Visual C++ 2008 SP1 Redistributable ( https://chocolatey.org/packages/vcredist2008 )
rem choco install -y vcredist2008
rem Microsoft Visual C++ 2010 Redistributable ( https://chocolatey.org/packages/vcredist2010 )
rem choco install -y vcredist2010
rem Microsoft Visual C++ 2012 Redistributable ( https://chocolatey.org/packages/vcredist2012 )
rem choco install -y vcredist2012
rem Visual C++ Redistributable Packages for Visual Studio 2013 ( https://chocolatey.org/packages/vcredist2013 )
rem choco install -y vcredist2013
rem Microsoft Visual C++ Redistributable for Visual Studio 2015 Update 3 (with hotfix 2016-09-14) ( https://chocolatey.org/packages/vcredist2015 )
rem choco install -y vcredist2015
rem Microsoft Visual C++ Redistributable for Visual Studio 2017 ( https://chocolatey.org/packages/vcredist2017 )
rem choco install -y vcredist2017
rem 7-Zip ( https://chocolatey.org/packages/7zip )
rem choco install -y 7zip
rem LibreOffice Fresh ( https://chocolatey.org/packages/libreoffice-fresh )
rem choco install -y libreoffice-fresh
@kiquenet
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment