206

Windows XP SP2 and Windows Vista have this deal where zone information is preserved in downloaded files to NTFS partitions, such that it blocks certain files in certain applications until you "unblock" the files.

So for example if you download a zip file of source code to try something out, every file will display this in the security settings of the file properties

"This file came from another computer and might be blocked to help protect this computer"

Along with an "Unblock" button. Some programs don't care, but Visual Studio will refuse to load projects in solutions until they've been unblocked.

While it's not terribly difficult to go to every project file and unblock it individually, it's a pain. And it does not appear you can unblock multiple selected files simultaneously.

Is there any way to unblock all files in a directory without having to go to them all individually?

I know you can turn this off globally for all new files but let's say I don't want to do that

Tom Kidd
  • 1,627

15 Answers15

211

If you download a .ZIP and unzip it, the individual files will be marked as the same zone as the .ZIP. Almost every time I have a folder full of "blocked" files, this is how I got them.

Before unzipping, click the Unblock button on the .ZIP.

antzshrek
  • 568
Jay Bazuzi
  • 4,210
120

PowerShell, available here, has an Unblock-File cmdlet that will do this task for you. To unblock all of the files in a directory, you'd issue the following command.

dir c:\mydir -Recurse | Unblock-File

Unblock-File doc

zwcloud
  • 290
pk.
  • 430
66

It's quite simple, NTFS attached a data stream (that IDs "unsafe files") to the file when it is just downloaded from the Internet.

Do recursively remove this stream for all files, follow these steps :

  1. Download the Streams CLI executable from Microsoft
  2. Put the streams.exe executable in your Windows directory (or anywhere that the system can find it)
  3. Run this line in the command line :

streams -s -d directory

It will then remove all of the data streams from all files recursively in the directory - you have now successfully unblocked all files.

caliban
  • 20,411
32

AlternateStreamView can list all alternate NTFS streams for files in a directory (and sub-directories if desired).

Delete all streams marked ":Zone.Identifier:$DATA" for the selected files to get rid of the security blocks.

enter image description here

Gareth
  • 19,080
Snark
  • 33,097
15

A very easy workaround for this kinda ties into the first answer, say if you have around 1000 files that are all blocked just take all the files, and put them in a new folder on your desktop (or whatever folder directory you're working in them right click said folder and then click Send To and then out of the options Click Compressed (zipped) Folder, then after that delete your original files and extract the .ZIP folder and Viola!!! all your files are unblocked :D, worked for me on XP Pro SP3, so kinda assuming it will work on vista as well

11

To disable blocking when files are downloaded, open the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments\SaveZoneInformation

Change SaveZoneInformation to 1.

NOTE:

  • 0 = Not Configured
  • 1 = Enabled
  • 2 = Disabled
Gareth
  • 19,080
8

As another poster said the insecure file flag is stored in an NTFS data stream. What this means is there's a very easy way to remove this data stream, just move the file to a drive that doesn't support NTFS data streams.

Assuming that your problem is more related to the number of files, rather than the size of them, then the easiest way to do it might be to move (not copy) the files to a FAT formatted drive, then move them back to the NTFS drive (almost every USB stick is formatted FAT32 so will do nicely), and then move those files back to where you want them.

I've done this before when I've wanted to strip the blocked flag from a whole directory of downloaded files and it did exactly what I needed.

GAThrawn
  • 4,360
8
  • Download the Sysinternals Streams utility.
  • Unzip and copy streams.exe to \Windows\System32.
  • Create a new text file and rename it to something like "unblocker.reg".
  • Copy the below registry script in it:

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\*\shell\unblockfile]
    @="Unblock file"
    
    [HKEY_CLASSES_ROOT\*\shell\unblockfile\command]
    @="cmd /c streams -d \"%1\""
    
    [HKEY_CLASSES_ROOT\Directory\shell\unblockallthefiles]
    @="Unblock the files inside"
    
    [HKEY_CLASSES_ROOT\Directory\shell\unblockallthefiles\command]
    @="cmd /c streams.exe -d -s \"%1\""
    
  • Save the file.

  • Double-click the saved file to merge it into the registry.

After this, whenever you right-click a file, you can select "Unblock file" in the context menu or you can right-click a folder and select "Unblock files in here".

source

5

AlternateStreamView is great. Another method though is to archive the files to .RAR, 7z or .ZIP . Delete the originals and then re-extract the files.

Indrek
  • 24,874
3

I had the same issue and the way I unblocked the files was:

  • I added all the blocked files to a RAR archive (I used WinRAR)
  • I removed the original files
  • I extracted all the files from the archive

All the files are now unblocked.

For me it was some MSDN Magazine issues that were in .chm format, but I do not think the file type matters.

slhck
  • 235,242
leoinfo
  • 81
1

I was searching for a batch method (without using powershell) and after reading this post I came up with this simple solution

echo. > .\filename.zip:Zone.Identifier

this will not remove the Zone.Identifier data stream but clear it's content which seems to work fine.

Another solution (which will clear all data streams and use a temporary file is this)

type filename.zip > filename.zip.tmp
move /y filename.zip.tmp filename.zip
1

ZoneIDTrimmer looks like the most user-friendly tool available for this:

enter image description here

RomanSt
  • 9,959
0

I have a usb external Hard Drive that works great for removing the blocks... I made a small partition and formatted it in FAT32..when I want to remove the block from something I simply move it to that drive and then move it back :-)

-4

Yes. At a command prompt, takeown /f <name of file>.

In your case, takeown /f *.* /r to recurse into all sub-directories and unblock *.*. Play with the pattern if necessary.

takeown /? for more usage instructions.

Peter Mounce
  • 708
  • 3
  • 9
  • 20
-5

There is another easy way. Just select the file or the folder, right click it and select Properties⇨Security⇨Edit, then click on Full Control.

After that you should just click [Save] and exit.

Synetech
  • 69,547