microsoft / Windows-Sandbox

Disposable, secure and lightweight Windows Desktop Environment
https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-sandbox/windows-sandbox-overview
MIT License
364 stars 49 forks source link

how to save Windows SandBox's state? #32

Closed HppZ closed 3 years ago

HppZ commented 3 years ago

I use WSB because I want an isolated container, not a clean container every time I launch it.

pbozzay commented 3 years ago

Hi,

Right now true persistence isn't supported in Sandbox. For that you can use a virtual machine with checkpoints. Another workaround is to map the data from your host via a mapped folder in the WSB file so that it is hydrated whenever the Sandbox is launched, and combine that with a startup script that installs programs that you need your Sandbox to have.

Foadsf commented 2 years ago

Dear Paul @pbozzay could you be kind to at least label this issue as a feature request? Windows Sadnboxes could be a great tool, however, in their current state, there is not much use to them. Some software requires a restart after installation. And many tasks might take more than a day and one can't leave a computer always on!

P.S.1. I created an official feature request through Feedback Hub here. More discussions here on Twitter.

P.S.2. I’d like to suggest exploring Application Virtualization (App-V) through the Microsoft application virtualization sequencer as a potential approach for those interested in this page. While it’s not a direct alternative to persistent sandboxes, App-V could offer a way to create contained environments that might serve some of the same needs.

roysubs commented 2 years ago

Persistence is now officially supported from Windows 11 build 22509 onwards (I'm not sure of the particulars of how you enable the persistence feature as I don't run Windows 11, but it's been officially stated by Microsoft).

roman6078 commented 2 years ago

Persistence is now officially supported from Windows 11 build 22509 onwards (I'm not sure of the particulars of how you enable the persistence feature as I don't run Windows 11, but it's been officially stated by Microsoft).

Do you have any official link /info snippet ?

Deemitry88 commented 2 years ago

Persistence is now officially supported from Windows 11 build 22509 onwards (I'm not sure of the particulars of how you enable the persistence feature as I don't run Windows 11, but it's been officially stated by Microsoft).

Do you have any official link /info snippet ?

here you go : https://learn.microsoft.com/fr-fr/windows/security/threat-protection/windows-sandbox/windows-sandbox-overview

VsevolodGolovanov commented 2 years ago

Persistence is now officially supported from Windows 11 build 22509 onwards (I'm not sure of the particulars of how you enable the persistence feature as I don't run Windows 11, but it's been officially stated by Microsoft).

The documentation states

Note, however, that as of Windows 11 Build 22509, your data will persist through a restart initiated from inside the virtualized environment useful for installing applications that require the OS to reboot.

and

Windows Sandbox now supports reboot inside of its virtualized environment (for example, if you were to click the Restart option under the Power button in Start).

So no, that's not quite what this issue talks about.

smokeyhallow commented 1 year ago

Not available for Windows 10?

doobes commented 1 year ago

Persistence on a Win10 box would be 'da bomb....

laggingreflex commented 5 months ago

As a workaround I was able to persist AppData and got msedge to retain its state:

    <MappedFolder>
      <HostFolder>D:\Sandbox\AppData</HostFolder>
      <SandboxFolder>C:\Users\WDAGUtilityAccount\AppData</SandboxFolder>
      <ReadOnly>False</ReadOnly>
    </MappedFolder>

But it messed up some features and icons. Maybe more stuff can be persisted this way.. I'd try copying the entire drive and select which parts I wanna preserve. Not sure if registry or other such settings would work...

valen214 commented 4 months ago

As a workaround I was able to persist AppData and got msedge to retain its state:

    <MappedFolder>
      <HostFolder>D:\Sandbox\AppData</HostFolder>
      <SandboxFolder>C:\Users\WDAGUtilityAccount\AppData</SandboxFolder>
      <ReadOnly>False</ReadOnly>
    </MappedFolder>

But it messed up some features and icons. Maybe more stuff can be persisted this way.. I'd try copying the entire drive and select which parts I wanna preserve. Not sure if registry or other such settings would work...

You can first copy the hydrated appdata to the host folder before actually mapping. It solves SOME of the problems. And exporting the whole (or a part of) registry before turning off the sandbox solves some other problems.