Batch file to unblock files copied from internet
Asked Answered
D

3

17

When we copy files (dll) from internet, Win7 blocks it. The unblock option appears as in the following image when we take the file properties. What command can I use to unblock the file from a batch file?

enter image description here

Dupleix answered 7/3, 2013 at 5:8 Comment(0)
I
12

Supposedly this should work:

echo.>myDownloadedFile.exe:Zone.Identifier

See a more detailed discussion here, Unblock a file with PowerShell?, which also describes other approaches using Powershell and the streams tool from SysInternals.

Irma answered 7/3, 2013 at 5:34 Comment(3)
For a filename with spaces in it, this works: echo.>"myDownloadedFile.exe":Zone.IdentifierScut
what does echo.> do ?Covenant
echo. echoes nothing, and > outputs this nothing to the specified file. Or in this case, to the zone identifier of the file.Irma
C
12

To do one is as per other suggestions. i.e either:

echo.>myDownloadedFile.dll:Zone.Identifier

or

Unblock-File myDownloadedFile.dll

but to do it 'bulk' as OP requested:

get-childitem *.jpg, *.gif | Unblock-File 

or in DOS:

FOR %a in (*.jpg *.gif) do (echo.>%a:Zone.Identifier)
Colton answered 22/7, 2016 at 3:47 Comment(2)
This bulk operation didn't work on Windows 10. I had to use double %.Flesher
@Flesher I tend towards Powershell solutions on Windows 10Colton
B
2

You can use streams -d path/to/file.zip This can be found here http://technet.microsoft.com/en-us/sysinternals/bb897440

Built answered 7/3, 2013 at 5:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.