Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off & setlocal EnableDelayedExpansion
- REM BOTH check #?
- :: Request admin permission
- net file >nul 2>&1 & if errorlevel 1 (
- echo. & echo Must be ran as ADMINISTRATOR& echo.
- pause & exit
- )
- set "this=%~0"
- set "installFolder=C:\Program Files\System Scripts"
- set "pathBackup=%temp%\SystemScripts_Install.txt"
- set "CSRP=%temp%\CSRP.txt"
- echo Native Scripts will be installed to:
- echo.
- echo. %installFolder%\
- echo.
- pause
- if not "%path:~990,1%" == "" (
- echo.** ERROR **
- echo. Fatal error. The PATH environment variable on this computer exceeds the length that can be safely modified by this installer.
- echo.** ERROR **
- pause& exit /b
- )
- REM Installer check #2
- :: 2. We might somehow fail to create %installFolder%, if it doesn't already exist
- if not exist "%installFolder%\" (
- md "%installFolder%" || (
- echo ERROR: Failure to create %installFolder%
- pause & exit /b
- )
- )
- REM -----------------------------------------------------------------------------------
- :: Create System Restore Point (CSRP)
- if not exist "%CSRP%" (
- wmic /namespace:\\root\default path SystemRestore call createrestorepoint "BATCH Restore", 100, 12
- <nul set /p ".=">%CSRP%
- )
- if not exist "%pathBackup%" echo %path%>"%pathBackup%"
- REM Installer check #1
- :: 1. The path might already contain the %installFolder% - but this is not necessarily a fatal error!
- call :getlength "%installFolder%"
- if "%path:~-1%" equ ";" ( set /a "length+=2" ) else ( set /a "length+=1 )
- if "%installFolder%\" equ "!path:~-%length%!" (
- setx /M path "%path%;%installFolder%\\" >nul
- )
- REM ------------------------------------------------------------------------------------------------------
- call :copyScripts
- echo. & echo Install successful. & echo.
- pause
- exit /b
- :getLength
- set "phrase=%~1"
- set length=0
- for %%a in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (
- if not "!phrase!" == "" if not "!phrase:~%%a,1!" == "" set /a length+=%%a&& set "phrase=!phrase:~%%a!"
- )
- if not "!phrase!" == "" set /a length+=1
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement