Skip to content
Windows Sandbox Utillities Python Package
Python
Branch: master
Clone or download

Latest commit

karkason Merge pull request #10 from karkason/feature/shell-extension
Added the ability to register and unregister a Windows Shell extensio…
Latest commit f8356eb Mar 31, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
tests Fix race in test_wait_for_file_creation between 2 calls to time.time() Mar 23, 2020
winsandbox Support directories with spaces Mar 31, 2020
.gitignore Add target directory Mar 22, 2020
LICENSE Initial commit Mar 21, 2020
MANIFEST.in
README.md
setup.py Version -> 1.1.0 Mar 30, 2020

README.md

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:

$ python3 -m pip install -U pywinsandbox

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

$ python3 -m pip 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
You can’t perform that action at this time.