Skip to main content

PyWinSandbox

Python Windows Sandbox library. Create a new Windows Sandbox machine, control it with a simple RPyC interface.

A good usage for this library would be to easily run sandboxed tests in a controlled envionment.

Quick Start

PyWinSandbox can be installed using pip:

$ pip3 install -U pywinsandbox

If you want to run the latest version of the code, you can install from git:

$ pip3 install -U git+git://github.com/karkason/pywinsandbox.git

Note that the Windows Sandbox should be enabled in your system in order to use PyWinSandbox. See the following Microsoft article on how to do that.

Examples

import winsandbox

sandbox = winsandbox.new_sandbox()
sandbox.rpyc.modules.subprocess.run('explorer .')

# Create a sandbox with a mapped directory.
# Directories are mapped under desktop.
sandbox = winsandbox.new_sandbox(folder_mappers=[winsandbox.FolderMapper(r'C:\users\public')])
tree = sandbox.rpyc.modules.subprocess.check_output(r'cmd /c tree %userprofile%\Desktop\public')

# Create an offline sandbox with a logon script.
sandbox = winsandbox.new_sandbox(networking=False, logon_script="explorer .")

Also a console script is available:

# wsb / winsandbox are aliases

# Create an interactive sandbox session. Spawns an IPython shell.
wsb -i

# Spawn an "offline" Windows Sandbox instance, with a command line.
wsb -s "explorer C:\windows\system32" 

Windows Shell Extension

A shell extension is also available to easily sandbox executables with the right click menu:

Shell Extension

# Run these commands with Administrator privileges

# Register the shell extension
wsb -r
# Unregister the shell extension
wsb -u

Release files for pywinsandbox 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pywinsandbox 1.4.0
File Size Uploaded
pywinsandbox-1.4.0.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pywinsandbox 1.4.0
File Interpreter ABI Platform
pywinsandbox-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.1 kB

Release files / pywinsandbox-1.4.0.tar.gz

Download URL pywinsandbox-1.4.0.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bb4c834eeb14f4c55f6a24b294b36f55995052f496b770bb85e49904c9db52fd
BLAKE2b-256 checksum
How to use checksums
7107bef04ca322a409c591c3fcc1cb068e874b19ade5276f8264a50b11f1e2f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / pywinsandbox-1.4.0-py3-none-any.whl

Download URL pywinsandbox-1.4.0-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
697894316e29b8dd49d1f1c4ca8ac5d8cccf35a5c7f19b394d024640d06e76fc
BLAKE2b-256 checksum
How to use checksums
4b03c516c1caecbca5afc02bd682d7093cc98242f251f98330793c78a5ff115f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page