Create and control a Windows Sandbox with Python
masterUse the winsandbox library to programmatically create Windows Sandbox instances. Once created, you can control the sandbox using an rpyc interface, which allows you to execute commands within the sandbox environment as if they were local Python modules.
Basic Usage
import winsandbox
sandbox = winsandbox.new_sandbox()
sandbox.rpyc.modules.subprocess.run('explorer .')Advanced Configuration
Map a local directory to the Sandbox Desktop
Directories provided via folder_mappers are mapped under the sandbox's Desktop.
sandbox = winsandbox.new_sandbox(folder_mappers=[winsandbox.FolderMapper(r'C:\users\public')])
# The folder is now accessible at %userprofile%\Desktop\publicCreate an offline sandbox with a logon script
Disable networking and specify a command to run immediately upon logon.
sandbox = winsandbox.new_sandbox(networking=False, logon_script="explorer .")Configure RAM allocation
Specify the amount of memory in MB.
sandbox = winsandbox.new_sandbox(memory_mb=8192)import winsandbox
sandbox = winsandbox.new_sandbox()
sandbox.rpyc.modules.subprocess.run('explorer .')