sandboxie-plus / sandboxie-docs

Sandboxie Documentation
https://sandboxie-plus.github.io/sandboxie-docs
71 stars 51 forks source link

WriteFilePath did not work for files #166

Closed hulinfan closed 3 months ago

hulinfan commented 7 months ago

I would like to hide some files outside the sandbox. For example:

WriteFilePath=D:\tmp\a.txt

But it doesn't work. I check the docs about write file path:
https://sandboxie-website-archive.github.io/www.sandboxie.com/WriteFilePath.html

Got that the file is treated as if it matches a ClosedFilePath.

My question is, it seems not technical hard to implement, but why 'WriteFilePath' not supports file? What's the aspect i've been missing?

offhub commented 7 months ago

I don't know the reason, but you can try the following methods.

For Sandboxie-Plus:

You can delete the file or create an empty copy of it from the sandbox using the Triggers feature.

delete:

AutoExec=cmd /c "del "<drive>:\<path>\<file>""

OR

empty copy:

AutoExec=cmd /c "type NUL > "<drive>:\<path>\<file>""

See AutoExec

AND/OR

You can use the Snapshot feature.

  1. Run sandboxed CMD.
  2. Delete the file (or change the contents of the file).
  3. Close sandboxed CMD.
  4. Right-click the sandbox > Sandbox Options > Snapshot Manager > Take Snapshot
  5. Unless you delete the snapshots, the files in that snapshot remain valid even if the contents of the box are deleted.
    • You can add files to the appropriate locations under Sandbox\Box\snapshot-x using unsandboxed Windows Explorer.

See BoxSnapshots

hulinfan commented 7 months ago

I don't know the reason, but you can try the following methods.

For Sandboxie-Plus:

You can delete the file or create an empty copy of it from the sandbox using the Triggers feature.

delete:

AutoExec=cmd /c "del "<drive>:\<path>\<file>""

OR

empty copy:

AutoExec=cmd /c "type NUL > "<drive>:\<path>\<file>""

See AutoExec

AND/OR

You can use the Snapshot feature.

  1. Run sandboxed CMD.
  2. Delete the file (or change the contents of the file).
  3. Close sandboxed CMD.
  4. Right-click the sandbox > Sandbox Options > Snapshot Manager > Take Snapshot
  5. Unless you delete the snapshots, the files in that snapshot remain valid even if the contents of the box are deleted.

    • You can add files to the appropriate locations under Sandbox\Box\snapshot-x using unsandboxed Windows Explorer.

See BoxSnapshots

Thanks offhub. Your information helps me a lot.