diff --git a/windows_install.bat b/windows_install.bat index 046f7ea..80ac762 100644 --- a/windows_install.bat +++ b/windows_install.bat @@ -1,7 +1,22 @@ -@echo off -title Setting up your machine for Selenium Testing! + @echo off + title Setting up your machine for Selenium Testing! + call :isAdmin -@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" + if %errorlevel% == 0 ( + goto :run + ) else ( + echo Requesting administrative privileges... + goto :UACPrompt + ) + + exit /b + + :isAdmin + fsutil dirty query %systemdrive% >nul + exit /b + + :run + @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" choco install firefox -y choco install googlechrome -y @@ -9,4 +24,15 @@ choco install phantomjs -y choco install selenium-all-drivers -y choco install jdk8 -y choco install maven -y -SETX PATH "%PATH%;C:\tools\selenium" \ No newline at end of file +SETX PATH "%PATH%;%ChocolateyToolsLocation%" + + exit /b + + :UACPrompt + echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" + echo UAC.ShellExecute "cmd.exe", "/c %~s0 %~1", "", "runas", 1 >> "%temp%\getadmin.vbs" + + "%temp%\getadmin.vbs" + del "%temp%\getadmin.vbs" + exit /B` +