Can 7-Zip Use Windows VSS to Compress Locked Files?

7-Zip cannot natively interact with the Windows Volume Shadow Copy Service (VSS) to read or compress live, locked system files. If you attempt to archive an open database, system file, or active registry hive directly with 7-Zip, the process will fail with an access-denied error. However, you can achieve this by pairing 7-Zip with Windows command-line utilities to manually generate a shadow copy, mount it, and run the compression against the resulting snapshot.

The Native Limitation of 7-Zip

When a file is actively opened by Windows or an application with an exclusive lock—such as NTUSER.DAT, Hyper-V virtual hard disks, or SQL databases—the file system blocks other processes from reading it.

Backup utilities handle this by calling the Volume Shadow Copy Service (VSS) API, which creates a point-in-time snapshot of the volume. 7-Zip does not implement VSS APIs in its graphical user interface (GUI) or its standard command-line utility (7z.exe). As a result, attempting to compress locked files directly leads to the standard Windows error: "The process cannot access the file because it is being used by another process."

How to Compress Locked Files with 7-Zip via VSS

To compress locked system files using 7-Zip, you must separate snapshot creation from compression. This requires creating a shadow copy first, exposing it to the file system, running 7-Zip, and then cleaning up the snapshot.

Step 1: Create a Shadow Copy Using Diskshadow

On Windows Server (or Windows clients with appropriate administrative tools installed), you can use the built-in diskshadow tool or third-party utilities like vshadow.exe.

Create a script file named vss_script.txt with the following commands:

set context persistent
set metadata C:\vss_metadata.cab
begin backup
add volume C: alias ShadowVolume
create
expose %ShadowVolume% X:

Execute this script in an elevated Command Prompt:

diskshadow -s vss_script.txt

This captures a snapshot of the C: drive and exposes it as a temporary virtual drive X:.

Step 2: Compress the Files with 7-Zip

Because the files on drive X: are static read-only snapshots, none of them are locked by active system processes. You can now target the files using the 7-Zip command line:

"C:\Program Files\7-Zip\7z.exe" a -t7z "C:\Backups\SystemBackup.7z" "X:\Windows\System32\config\*"

Step 3: Remove the Shadow Copy

After 7-Zip completes the archive, unmount and delete the shadow copy to free system storage:

Create a cleanup script named vss_cleanup.txt:

unexpose X:
delete shadows exposed X:
end backup

Run the cleanup script:

diskshadow -s vss_cleanup.txt

Alternatives for Scripting and Automation

If managing raw VSS scripts is too complex, consider these alternatives:

  • Hobocopy or ShadowSpawn: Lightweight open-source utilities designed to invoke VSS on the fly for a single command, allowing you to run shadowspawn C:\LockedDir Q: "7z a backup.7z Q:\*" directly.
  • PowerShell Scripts: PowerShell scripts utilizing WMI or the VssAdmin tool can automate the creation, symbolic linking (via mklink /d), and deletion of shadow copies before and after running 7-Zip.
  • Dedicated Backup Software: If you require continuous, seamless backups of locked files without custom scripting, utilities that include built-in VSS integration (such as Macrium Reflect, Veeam, or Duplicati) are recommended over standalone 7-Zip.