Advertisement
Guest User

Untitled

a guest
Feb 6th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off & setlocal EnableDelayedExpansion
  2.  
  3. REM BOTH check #?
  4.     :: Request admin permission
  5.         net file >nul 2>&1 & if errorlevel 1 (
  6.             echo. & echo   Must be ran as ADMINISTRATOR& echo.
  7.             pause & exit
  8.         )
  9.    
  10. set "this=%~0"
  11. set "installFolder=C:\Program Files\System Scripts"
  12. set "pathBackup=%temp%\SystemScripts_Install.txt"
  13. set "CSRP=%temp%\CSRP.txt"
  14.  
  15.  
  16.  
  17.  
  18. echo Native Scripts will be installed to:
  19. echo.
  20. echo.  %installFolder%\
  21. echo.
  22. pause
  23.  
  24. if not "%path:~990,1%" == "" (
  25.     echo.** ERROR **
  26.     echo.  Fatal error.  The PATH environment variable on this computer exceeds the length that can be safely modified by this installer.
  27.     echo.** ERROR **
  28.     pause& exit /b
  29. )
  30.  
  31.    
  32.     REM Installer check #2
  33.         :: 2.  We might somehow fail to create %installFolder%, if it doesn't already exist
  34.     if not exist "%installFolder%\" (
  35.         md "%installFolder%" || (
  36.             echo ERROR: Failure to create %installFolder%
  37.             pause & exit /b
  38.         )
  39.     )
  40.     REM -----------------------------------------------------------------------------------
  41.    
  42.    
  43.     :: Create System Restore Point (CSRP)
  44.     if not exist "%CSRP%" (
  45.         wmic /namespace:\\root\default path SystemRestore call createrestorepoint "BATCH Restore", 100, 12
  46.         <nul set /p ".=">%CSRP%
  47.     )
  48.            
  49.         if not exist "%pathBackup%" echo %path%>"%pathBackup%"
  50.        
  51.        
  52.         REM Installer check #1
  53.             :: 1.  The path might already contain the %installFolder% - but this is not necessarily a fatal error!
  54.             call :getlength "%installFolder%"
  55.            
  56.             if "%path:~-1%" equ ";" ( set /a "length+=2" ) else ( set /a "length+=1 )
  57.            
  58.            if "%installFolder%\" equ "!path:~-%length%!" (
  59.                 setx /M path "%path%;%installFolder%\\" >nul
  60.             )
  61.         REM ------------------------------------------------------------------------------------------------------
  62.        
  63.         call :copyScripts
  64.  
  65.     echo. & echo   Install successful. & echo.
  66.     pause
  67. exit /b
  68.  
  69. :getLength
  70. set "phrase=%~1"
  71. set length=0
  72. for %%a in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (
  73.     if not "!phrase!" == "" if not "!phrase:~%%a,1!" == "" set /a length+=%%a&& set "phrase=!phrase:~%%a!"
  74. )
  75. if not "!phrase!" == "" set /a length+=1
  76. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement