VOOZH about

URL: https://dev.to/karenpayneoregon/mark-of-the-web-remover-14kc

⇱ Mark of the web remover - DEV Community


Mark of the web remover

A utility to remove mark of the web from a folder recursively to all sub-folders.

If after downloading and un-zipping a archive file with perhaps a Visual Studio solution the files extracted may have been blocked, with this utility close Visual Studio, run this utility on the folder than re-open Visual Studio.

Current arguments (change to suite your environment)

Base code

public static void UnblockFiles(string folderName)
{
 if (!Directory.Exists(folderName))
 {
 return ;
 }

 var start = new ProcessStartInfo
 {
 FileName = "powershell.exe",
 RedirectStandardOutput = true,
 Arguments = $"Get-ChildItem -Path '{folderName}' -Recurse | Unblock-File",
 CreateNoWindow = true, 
 UseShellExecute = false
 };

 using var process = Process.Start(start);
 process.WaitForExit();
}

Tool

Without this tool a developer must right click on each and every file, go to properties and un-check mark of the web and click apply or write a PowerShell script (this tool uses PowerShell).

The only drawback is perhaps forgetting the tool name which is easy here. From a command window or PowerShell window type dotnet tool list --global and press .

👁 screen shot

After the tool runs all files that may had mark of the web are devoid of mark of the web including all sub-folders.

Install/uninstall

dotnet tool install --global --add-source ./nupkg MarkOfTheWeb
dotnet tool uninstall -g MarkOfTheWeb

Run without arguments

👁 screen shot

Run with arguments

Here a .zip file was downloaded and files extracted which at that point several files had mark of the web.

👁

Install from Nuget

dotnet tool install --global MarkOfTheWeb --version 1.0.1

Full source

See the following GitHub repository.

PowerShell

For those who want to run in a terminal

dir -Path [directory path] -Recurse | Unblock-File
Get-ChildItem -Path '[directory path]' -Recurse | Unblock-File