Created
June 22, 2013 20:41
-
-
Save zemd/5842507 to your computer and use it in GitHub Desktop.
install pyrus
This file contains hidden or 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
| :: Apache License, Version 2.0 | |
| :: http://www.apache.org/licenses/LICENSE-2.0 | |
| :: Copyright 2012 Dmitry Zelenetskiy (dmitry.zelenetskiy@gmail.com) | |
| @ECHO OFF | |
| VERIFY OTHER 2>nul | |
| SETLOCAL ENABLEEXTENSIONS | |
| IF ERRORLEVEL 1 ECHO Unable to enable extensions | |
| IF DEFINED PYRUS_HOME (GOTO PYRUS_RUN) ELSE (GOTO PYRUS_NOT_INSTALLED) | |
| IF DEFINED PYRUS_REP (SET PYRUS_REP %PYRUS_REP%) ELSE (SET PYRUS_REP %PYRUS_HOME%\packages) | |
| ENDLOCAL | |
| @ECHO ON | |
| :PYRUS_NOT_INSTALLED | |
| :: BatchGotAdmin | |
| :------------------------------------- | |
| REM --> Check for permissions | |
| >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
| REM --> If error flag set, we do not have admin. | |
| if '%errorlevel%' NEQ '0' ( | |
| echo Requesting administrative privileges... | |
| goto UACPrompt | |
| ) else ( goto gotAdmin ) | |
| GOTO EOF | |
| :UACPrompt | |
| echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" | |
| echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" | |
| "%temp%\getadmin.vbs" | |
| exit /B | |
| :gotAdmin | |
| if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) | |
| pushd "%CD%" | |
| CD /D "%~dp0" | |
| :-------------------------------------- | |
| ECHO. | |
| ECHO %%PYRUS_HOME%% ENVIRONMENT VARIABLE HAS TO BE DEFINED | |
| ECHO. | |
| :: Prompt user to enter PYRUS_HOME path | |
| SET /P PYRUS_HOME_VAL=Set variable path (default %~dp0): | |
| :: If user pressed ENDER then setting default value | |
| IF ERRORLEVEL 1 ( | |
| SET PYRUS_HOME_VAL=%~dp0 | |
| SET ERRORLEVEL=0 | |
| ) | |
| :: Set environment variables permanently | |
| SETX PYRUS_HOME %PYRUS_HOME_VAL% /M | |
| SETX PATH "%PYRUS_HOME_VAL%;%PATH%" /M | |
| :: Download pyrus | |
| GOTO PYRUS_INSTALL | |
| :PYRUS_INSTALL | |
| ECHO Downloading pyrus to: %PYRUS_HOME_VAL%pyrus.phar | |
| ECHO. | |
| curl --url http://pear2.php.net/pyrus.phar --output %PYRUS_HOME_VAL%pyrus.phar | |
| ECHO. | |
| exit | |
| :REFRESH_ENV | |
| echo Set oShell = WScript.CreateObject("WScript.Shell") > "%temp%\1.vbs" | |
| echo filename = oShell.ExpandEnvironmentStrings("%TEMP%\resetvars.bat") >> "%temp%\1.vbs" | |
| echo Set objFileSystem = CreateObject("Scripting.fileSystemObject") >> "%temp%\1.vbs" | |
| echo Set oFile = objFileSystem.CreateTextFile(filename, TRUE) >> "%temp%\1.vbs" | |
| echo set oEnv=oShell.Environment("Process") >> "%temp%\1.vbs" | |
| echo for each sitem in oEnv >> "%temp%\1.vbs" | |
| echo oFile.WriteLine("SET " & sitem) >> "%temp%\1.vbs" | |
| echo next >> "%temp%\1.vbs" | |
| echo oFile.Close >> "%temp%\1.vbs" | |
| "%temp%\1.vbs" | |
| exit | |
| :PYRUS_RUN | |
| php %PYRUS_HOME%\pyrus.phar %* | |
| GOTO EOF | |
| :EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment