T3RRYT3RR0R

Zone_Identifier_remover

Jul 12th, 2026 (edited)
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.25 KB | Source Code | 0 0
  1. @Echo off
  2. CD /D "%~dp0"
  3. Setlocal EnableExtensions DisableDelayedExpansion
  4. REM this script removes the Zone.Identifier Aletrnate Data Stream from all .bat
  5. REM files in this directory and it's subdirectories
  6. REM An ADS is automatically embedded by windows when a file is downloaded.
  7. REM .bat with a ZoneIdentifier that flags as non-local will trigger the UAC prompt when run
  8.  
  9. REM Positive affirmation of intent
  10.   Echo( Confirm  Y / N
  11.   Echo( Do you want to remove The ZoneIdentifier Stream from all .bat file in "%~dp0"
  12.   For /f "Delims=" %%K in ('Choice /N /C:YN') Do Call:%%K
  13.   Pause
  14. exit /b 0
  15.  
  16. :Y
  17.  
  18.   For /f "delims=" %%G in ('%systemroot%\system32\where.exe PowerShell.exe')Do if not defined powershell Set powershell="%%~G"
  19.   Set /a removed=ignored=0,last=1
  20.  
  21.   For /f "Delims=" %%G in ('dir /b /s /a:-D *.bat') Do (
  22.     1> nul 2> nul %powershell% -c "remove-item -path '%%~fG' -Stream 'Zone.Identifier'
  23.     If not errorlevel 1 (
  24.       2> nul Set /a "1/last" || Echo(
  25.       Echo Removed stream from: "%%~fG"
  26.       Set /a removed += 1, last=1
  27.     ) else (
  28.       <nul set /p "=."
  29.       Set /a ignored += 1, last=0
  30.     )
  31.     (Call )
  32.   )
  33.   Echo(
  34.   Echo( Streams removed:%removed% ignored:%ignored%
  35. Exit /b 0
  36.  
  37. :N
  38.   Echo No action taken
  39. Exit /b 0
Advertisement
Add Comment
Please, Sign In to add comment