“此文件来自另一台计算机...”中的答案-如何取消阻止文件夹中的所有文件而不必分别取消阻止它们?解释如何“取消阻止”来自远程源的文件。出于测试目的,我想完成相反的操作。如何设置文件的区域标识符,以便Windows可以“阻止”该文件?
我只喜欢PowerShell解决方案,但是可以接受其他机制。
下载文件后,您可能会注意到在文件属性对话框中还有一个Security
带有Unblock
复选框的附加部分:
有关文件的此附加数据存储在备用数据流(ADS)中。可以使用多种方法(例如Streams)以多种方式查看备用数据流,但现在使用PowerShell可以更方便地进行查看。
例如,要查看文件的所有流,可以使用以下PowerShell命令:
Get-Item -Path Autologon.exe -Stream *
输出如下:
PSPath : Microsoft.PowerShell.Core\FileSystem::C:\ads\Autologon.exe::$DATA
PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\ads
PSChildName : Autologon.exe::$DATA
PSDrive : C
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : False
FileName : C:\ads\Autologon.exe
Stream : :$DATA
Length : 138920
PSPath : Microsoft.PowerShell.Core\FileSystem::C:\ads\Autologon.exe:Zone.Identifier
PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\ads
PSChildName : Autologon.exe:Zone.Identifier
PSDrive : C
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : False
FileName : C:\ads\Autologon.exe
Stream : Zone.Identifier
Length : 26
出于这个问题的目的,这是Zone.Identifier
我们感兴趣的信息流。
要手动添加或更新Zone.Identifier
命名流并设置流的值,我们可以运行以下PowerShell命令:
Set-Content -Path .\file.exe -Stream Zone.Identifier -Value '[ZoneTransfer]','ZoneId=3'
其中ZoneId
指定的值可以是以下值之一:
0 = "Local machine"
1 = "Local intranet"
2 = "Trusted sites"
3 = "Internet"
4 = "Restricted sites"
注意:要从ZoneTransfer
文件中删除流并因此执行与从文件属性对话框中取消阻止文件相同的操作,可以运行以下命令之一:
Unblock-File -path .\file.exe
Remove-Item -Path .\file.exe -Stream Zone.Identifier
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句