Last active
January 6, 2017 15:59
-
-
Save warrenbuckley/b4cbaca678d884f7460efe26eb4c043c to your computer and use it in GitHub Desktop.
A work in progress Batch file to automate downloading & installing Visual Studio Code, the IIS Express VS Code extension & IISExpress itself if its not installed already
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ECHO OFF | |
rem Check if VS Code is installed - Checks if its in the path | |
rem Not 100% sure best way as think installer allows yout to NOT put it in the %PATH% | |
CALL where /q code | |
IF ERRORLEVEL 1 ( | |
ECHO Visual Studio Code is not installed. | |
ECHO Downloading installer from https://vscode-update.azurewebsites.net/latest/win32/stable | |
rem Download the file & name it VSCodeSetup.exe relative to this running batch file | |
CALL powershell -Command "(New-Object Net.WebClient).DownloadFile('https://vscode-update.azurewebsites.net/latest/win32/stable', 'VSCodeSetup.exe')" | |
rem Run the installer & ensure it does not launch after install | |
rem https://github.com/Microsoft/vscode/issues/860 | |
rem CALL VSCodeSetup.exe /verysilent | |
CALL VSCodeSetup.exe /silent /mergetasks=!runcode | |
) | |
rem Install the IIS Express VS Code extension | |
CALL code --install-extension warren-buckley.iis-express | |
ECHO %ERRORLEVEL% | |
IF ERRORLEVEL 1 ( | |
ECHO Already have IIS Express extension installed - use VSCode to upgrade extension | |
) | |
rem Checks what OS type we are running - need to know for the IISExpress Installer we download | |
rem http://stackoverflow.com/questions/12322308/batch-file-to-check-64bit-or-32bit-os | |
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && SET OS=32BIT || SET OS=64BIT | |
IF %OS%==32BIT ( | |
ECHO This is a 32bit operating system | |
SET IISEXPATH="%ProgramFiles(x86)%\IIS Express\iisexpress.exe" | |
) | |
IF %OS%==64BIT ( | |
ECHO This is a 64bit operating system | |
SET IISEXPATH="%ProgramFiles%\IIS Express\iisexpress.exe" | |
) | |
rem Check for IISExpress is installed | |
ECHO The path to IISExpress we use to check if it exists and is installed is '%IISEXPATH%' | |
rem Execute the IISExpress.exe with the help /? argument switch (To determine if it exists) | |
%IISEXPATH% /? | |
ECHO %ERRORLEVEL% | |
IF ERRORLEVEL 9009 ( | |
rem 9009 Seems to be file not found error | |
rem Download IIS Express installer | |
IF %OS%==64BIT ( | |
ECHO Downloading 64Bit IIS Express installer from 'https://download.microsoft.com/download/C/E/8/CE8D18F5-D4C0-45B5-B531-ADECD637A1AA/iisexpress_amd64_en-US.msi' | |
rem Download the file & name it IISExpressSetup.msi relative to this running batch file | |
CALL powershell -Command "(New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/C/E/8/CE8D18F5-D4C0-45B5-B531-ADECD637A1AA/iisexpress_amd64_en-US.msi', 'IISExpressSetup.msi')" | |
) | |
IF %OS%==32BIT ( | |
ECHO Downloading 64Bit IIS Express installer from 'https://download.microsoft.com/download/C/E/8/CE8D18F5-D4C0-45B5-B531-ADECD637A1AA/iisexpress_x86_en-US.msi' | |
rem Download the file & name it IISExpressSetup.msi relative to this running batch file | |
CALL powershell -Command "(New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/C/E/8/CE8D18F5-D4C0-45B5-B531-ADECD637A1AA/iisexpress_x86_en-US.msi', 'IISExpressSetup.msi')" | |
) | |
rem Run the installer for IIS Express /passive (Just shows the progress bar) | |
CALL IISExpressSetup.msi /passive | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment