Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for bootini.bat

(view source code of bootini.bat as plain text)

  1. @ECHO OFF
  2. ECHO.
  3.  
  4. :: No command line parameters needed:
  5. IF NOT "%1"=="" GOTO Syntax
  6.  
  7. :: Windows NT only:
  8. VER | FIND "Windows NT" >NUL
  9. IF ERRORLEVEL 1 GOTO Syntax
  10.  
  11. :: Check if BOOT.INI exists; if it doesn't,
  12. :: display a warning message and quit:
  13. IF NOT EXIST %SystemDrive%\BOOT.INI (ECHO BOOT.INI not found.&ECHO Correct the problem and try again.&GOTO:EOF)
  14.  
  15. :: Check if backup file exists; if it does,
  16. :: display a warning message and quit:
  17. IF EXIST %SystemDrive%\BOOT.BAK (ECHO Backup of BOOT.INI ^(BOOT.BAK^) already exists.&ECHO Rename it and try again.&GOTO:EOF)
  18.  
  19. :: Display original file:
  20. ECHO Original BOOT.INI:
  21. ECHO.
  22. TYPE %SystemDrive%\BOOT.INI
  23. ECHO.
  24.  
  25. :: Remove file attributes:
  26. ATTRIB -H -S -R %SystemDrive%\BOOT.INI
  27. :: Rename BOOT.INI for backup purposes:
  28. REN %SystemDrive%\BOOT.INI *.BAK
  29. :: Read renamed BOOT.INI and write each line to the
  30. :: new BOOT.INI, modifying only the timeout value:
  31. (FOR /F "tokens=1* delims==" %%A IN (%SystemDrive%\BOOT.BAK) DO IF "%%B"=="" (ECHO %%A) ELSE (IF /I "%%A"=="timeout" (ECHO %%A=5) ELSE (ECHO %%A=%%B)))>%SystemDrive%\BOOT.INI
  32. :: Restore the file attributes:
  33. ATTRIB +H +S +R %SystemDrive%\BOOT.INI
  34.  
  35. :: Display the modifications:
  36. ECHO Modified BOOT.INI:
  37. ECHO.
  38. TYPE %SystemDrive%\BOOT.INI
  39. ECHO.
  40.  
  41. :: Safety check; if no BOOT.INI exists, restore the backup:
  42. IF NOT EXIST %SystemDrive%\BOOT.INI (ECHO Restoring original BOOT.INI&COPY %SystemDrive%\BOOT.BAK %SystemDrive%\BOOT.INI)
  43.  
  44. :: End program
  45. GOTO:EOF
  46.  
  47. :Syntax
  48. ECHO BOOTINI.BAT,  Version 1.00 for Windows NT
  49. ECHO Changes BOOT.INI's timeout value to 5 seconds.
  50. ECHO The original BOOT.INI is stored as BOOT.BAK.
  51. ECHO.
  52. ECHO Written by Rob van der Woude
  53. ECHO http://www.robvanderwoude.com
  54. ECHO.
  55. ECHO DISCLAIMER:
  56. ECHO Incorrect changes to BOOT.INI may prevent the system to boot next time.
  57. ECHO Use this tool entirely at your own risk.
  58. ECHO Do not use this tool unless you know how to repair any possible damage.
  59. GOTO:EOF
  60.  

page last modified: 2024-04-16; loaded in 0.0176 seconds