Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for bootini2.bat

(view source code of bootini2.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. :: Check if this update has been done before,
  26. :: to prevent adding the switch more than once:
  27. TYPE %SystemDrive%\BOOT.INI | FIND /I " /NoSerialMice" >NUL
  28. :: If the update has been done before, display a message and quit:
  29. IF NOT ERRORLEVEL 1 (ECHO The "/NoSerialMice" switch has been added before.&ECHO Aborting...&GOTO End)
  30.  
  31. :: Remove file attributes:
  32. ATTRIB -H -S -R %SystemDrive%\BOOT.INI
  33. :: Rename BOOT.INI for backup purposes:
  34. REN %SystemDrive%\BOOT.INI *.BAK
  35. :: Read renamed BOOT.INI and write each line to the
  36. :: new BOOT.INI, only adding the /NoSerialMice value:
  37. (FOR /F "tokens=1* delims==" %%A IN (%SystemDrive%\BOOT.BAK) DO (
  38. 	IF "%%B"=="" (
  39. 		ECHO %%A
  40. 	) ELSE (
  41. 		ECHO.%%A | FIND "partition" >NUL
  42. 		IF ERRORLEVEL 1 (
  43. 			ECHO %%A=%%B
  44. 		) ELSE (
  45. 			ECHO %%A=%%B /NoSerialMice
  46. 		)
  47. 	)
  48. ))>%SystemDrive%\BOOT.INI
  49.  
  50. :: Restore the file attributes:
  51. ATTRIB +H +S +R %SystemDrive%\BOOT.INI
  52.  
  53. :: Display the modifications:
  54. ECHO Modified BOOT.INI:
  55. ECHO.
  56. TYPE %SystemDrive%\BOOT.INI
  57. ECHO.
  58.  
  59. :: Safety check; if BOOT.INI exists end program, otherwise restore the backup:
  60. IF EXIST %SystemDrive%\BOOT.INI GOTO End
  61.  
  62. :: If you arrived here, BOOT.INI wasn't found and needs to be restored:
  63. :Restore
  64. ECHO Restoring original BOOT.INI
  65. COPY %SystemDrive%\BOOT.BAK %SystemDrive%\BOOT.INI
  66.  
  67. :: End program
  68. :End
  69. GOTO:EOF
  70.  
  71. :Syntax
  72. ECHO BOOTINI2.BAT,  Version 2.01 for Windows NT
  73. ECHO Adds /NoSerialMice switch to the operating system lines in BOOT.INI.
  74. ECHO The original BOOT.INI is stored as BOOT.BAK.
  75. ECHO.
  76. ECHO Written by Rob van der Woude
  77. ECHO http://www.robvanderwoude.com
  78. ECHO.
  79. ECHO DISCLAIMER:
  80. ECHO Incorrect changes to BOOT.INI may prevent the system to boot next time.
  81. ECHO Use this tool entirely at your own risk.
  82. ECHO Do not use this tool unless you know how to repair any possible damage.
  83. GOTO:EOF
  84.  

page last uploaded: 2017-04-06, 13:33