Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for nobrowse.bat

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

  1. @ECHO OFF
  2. :: Windows NT 4 / 2000 only
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4. :: Not for servers, for workstations only
  5. FOR /F "skip=8 tokens=2 delims=:" %%A IN ('NET ACCOUNTS') DO FOR /F "tokens=1 delims= " %%K IN ('ECHO.%%A') DO IF /I NOT "%%K"=="WORKSTATION" GOTO Syntax
  6.  
  7. :: Rollback
  8. ECHO Creating a rollback file . . .
  9. START /WAIT REGEDIT /E "%Temp%.\BrowseRollBack.reg" "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Browser\Parameters"
  10. IF NOT EXIST "%Temp%.\BrowseRollBack.reg" (
  11. 	ECHO Error creating rollback file, aborting . . .
  12. 	GOTO End
  13. )
  14. ECHO A rollback file has been created:
  15. ECHO "%Temp%.\BrowseRollBack.reg"
  16. ECHO Doubleclick this file if you want to restore the original settings later.
  17. ECHO.
  18.  
  19. ECHO Creating temporary file . . .
  20. > %Temp%.\NoBrowse.reg ECHO REGEDIT4
  21. >>%Temp%.\NoBrowse.reg ECHO.
  22. >>%Temp%.\NoBrowse.reg ECHO [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Browser\Parameters]
  23. >>%Temp%.\NoBrowse.reg ECHO "IsDomainMaster"="No"
  24. >>%Temp%.\NoBrowse.reg ECHO "MaintainServerList"="No"
  25. >>%Temp%.\NoBrowse.reg ECHO.
  26. IF NOT EXIST "%Temp%.\NoBrowse.reg" (
  27. 	ECHO Error creating temporary file, aborting . . .
  28. 	GOTO End
  29. )
  30.  
  31. ECHO Changing registry settings . . .
  32. START /WAIT REGEDIT /S %Temp%.\NoBrowse.reg
  33.  
  34. ECHO Removing temporary file
  35. DEL %Temp%.\NoBrowse.reg
  36.  
  37. ECHO Done
  38. GOTO End
  39.  
  40.  
  41. :Syntax
  42. ECHO.
  43. ECHO NoBrowse.bat,  Version 1.00 for Windows NT 4 / 2000
  44. ECHO Prevent the local workstation from becoming a domain browser master
  45. ECHO.
  46. ECHO Usage:  NOBROWSE
  47. ECHO.
  48. ECHO Written by Rob van der Woude
  49. ECHO http://www.robvanderwoude.com
  50.  
  51. :End
  52.  

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