Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for unblock.bat

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

  1. @ECHO OFF
  2. :: Check Windows version: minimum requirement Windows
  3. :: 2000, but useful only for Windows XP SP2 and later
  4. IF NOT "%OS%"=="Windows_NT"     GOTO Syntax
  5. VER | FIND "Windows NT" >NUL && GOTO Syntax
  6. :: Check command line arguments
  7. IF      "%~1"==""               GOTO Syntax
  8. IF NOT  "%~2"==""               GOTO Syntax
  9. IF NOT EXIST "%~1"              GOTO Syntax
  10.  
  11. :: Localize variable
  12. SETLOCAL
  13. SET ZoneId=
  14.  
  15. :: Retrieve current ZoneId
  16. FOR /F "tokens=*" %%A IN ('MORE ^< "%~f1":Zone.Identifier 2^>NUL ^| FIND "="') DO SET %%A
  17.  
  18. :: Modify existing ZoneId, but don't add one
  19. IF NOT "%ZoneId%"=="" (
  20. 	ECHO Current Zone Identifier:
  21. 	ECHO.
  22. 	MORE < "%~f1":Zone.Identifier
  23. 	>  "%~f1":Zone.Identifier ECHO [ZoneTransfer]
  24. 	>> "%~f1":Zone.Identifier ECHO ZoneId=1
  25. 	ECHO.
  26. 	ECHO New Zone Identifier:
  27. 	ECHO.
  28. 	MORE < "%~f1":Zone.Identifier
  29. ) ELSE (
  30. 	ECHO.
  31. 	ECHO The file currently has no Zone Identifier.
  32. 	ECHO Skipped "%~nx1" . . .
  33. )
  34.  
  35. :: Done
  36. ENDLOCAL
  37. GOTO:EOF
  38.  
  39.  
  40. :Syntax
  41. ECHO.
  42. ECHO UnBlock.bat,  Version 1.00 for Windows 2000 and later
  43. ECHO Change a downloaded file's zone identifier to fool XP SP2's zone
  44. ECHO checking mechanism into thinking the file was downloaded from the
  45. ECHO local intranet and is safe to execute.
  46. ECHO.
  47. ECHO Usage      : UNBLOCK  filename
  48. ECHO.
  49. ECHO Where      : "filename"  is the file to be marked safe to execute
  50. ECHO.
  51. ECHO More info  : http://support.microsoft.com/?kbid=883260
  52. ECHO              http://support.microsoft.com/?kbid=889815
  53. ECHO              http://support.microsoft.com/?kbid=105763
  54. ECHO.
  55. ECHO Disclaimer : By manually marking a file safe you effectively disable
  56. ECHO              the zone checking security mechanism for that file.
  57. ECHO              This is absolutely NOT recommended!!!
  58. ECHO              Use this batch file entirely at your own risk.
  59. ECHO.
  60. ECHO Based on an article by Bill Stewart in Windows Scripting Solutions
  61. ECHO http://www.windowsitpro.com/windowsscripting/
  62. ECHO.
  63. ECHO Written by Rob van der Woude
  64. ECHO http://www.robvanderwoude.com
  65.  

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