Run file in Windows Sandbox from right-click and Context menu
https://sddevblog.blogspot.com/2019/10/run-file-in-windows-sandbox-from-right.html
In this post I will share with you a solution, called Run in Sandbox, I developed that allows you to run directly a PS1, VBS, msi or EXE from a context menu, after doing a right-click on the file.
PreRequisites
- At least Windows 10 1903
- Windows Sandbox feature enable
What is the purpose ?
1 / You want to test a specific PS1 or EXE file in an isolated environment.
2 / A right-click on this file will display a new context menu, Run in Sandbox
3 / Once you click on it, a WSB file will be generated on your desktop with a startup command to run the specific PS1 file
4 / Then the Sandbox will be automatically launched with this configuration
How to get it ?
How to implement it ?
1 / Download the file
2 / Extract the archive
3 / Run the file Add_Sandbox_ContextMenu.ps1
4 / Context menus will be added for ps1, vbs, ex and msi files
5 / A folder Run_in_Sandbox will be copied in C:\ProgramData
Configuration
Once you run a file in Sandbox, a WSB file will be generated.
The startup command will be created using the file path and type (ex, ps1, vbs, msi)
The folder of the file will be added as sharedfolder
The VGpu and Networking options are enabled by default
You can change that on the file Sandbox_Config.xml located in the Run_in_Sandbox folder
How to use it ?
Run PS1 in Sandbox
There are two ways
- Run a simple PS1
- Run a PS1 with specific parameters (a GUI will be displayed to type parameters)
Simple PS1
1 / Choose the PS1 you want to run in Sandbox
2 / Do a right-click on the PS1 file
3 / Select Run the PS1 in Sandbox
4 / A Sandbox config file will be generated on your desktop using the file name
5 / The Sandbox will be automatically launched with the specific configuration
PS1 with parameters
1 / Choose the PS1 you want to run in Sandbox
2 / Do a right-click on the PS1 file
3 / Select Run the PS1 in Sandbox with parameters
4 / A GUI will be displayed
5 / Type parameters to add to the commandline
6 / A Sandbox config file will be generated on your desktop
7 / The Sandbox will be automatically launched with the specific configuration
Run EXE in Sandbox
1 / Choose the EXE you want to run in Sandbox
2 / Do a right-click on the EXE file
3 / Select Run the EXE in Sandbox
4 / A GUI will be displayed
5 / Type switches to add to the commandline
6 / A Sandbox config file will be generated on your desktop
7 / The Sandbox will be automatically launched with the specific configuration
In the below example, I didn't add switches so it won't be a silent install.
1 / Choose the msi you want to run in Sandbox
2 / Do a right-click on the msi file
3 / Select Run the msi in Sandbox
4 / A GUI will be displayed
6 / A Sandbox config file will be generated on your desktop
7 / The Sandbox will be automatically launched with the specific configuration
In the below example, I didn't add switches so it won't be a silent install.
Run VBS in Sandbox
There are two ways
- Run a simple VBS
- Run a VBS with specific parameters (a GUI will be displayed to type parameters)
Simple VBS
1 / Choose the VBS you want to run in Sandbox
2 / Do a right-click on the VBS file
3 / Select Run the VBS in Sandbox
4 / A Sandbox config file will be generated on your desktop
5 / The Sandbox will be automatically launched with the specific configuration
VBS with parameters
1 / Choose the VBS you want to run in Sandbox
2 / Do a right-click on the VBS file
3 / Select Run the VBS in Sandbox with parameters
4 / A GUI will be displayed
6 / A Sandbox config file will be generated on your desktop
7 / The Sandbox will be automatically launched with the specific configuration