Loading...

Run file in Windows Sandbox from right-click and Context menu

8 A+ A-

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.

Run msi in Sandbox
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
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.

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
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
Windows_Sandbox 7612196203490402066

Enregistrer un commentaire

8 commentaires

Baptiste a dit…

I can't launch any EXE software with it
How to uninstall-it ? please help ! :(

Anonyme a dit…

Please admin start with cmd and paste code

rd /s /q "%programdata%\Run_in_Sandbox"
Reg.exe delete "HKLM\SOFTWARE\Classes\Microsoft.PowerShellScript.1\Shell\Run the PS1 in Sandbox" /f
Reg.exe delete "HKLM\SOFTWARE\Classes\Microsoft.PowerShellScript.1\Shell\Run the PS1 in Sandbox with parameters" /f
Reg.exe delete "HKLM\SOFTWARE\Classes\VBSFile\Shell\Run the VBS in Sandbox" /f
Reg.exe delete "HKLM\SOFTWARE\Classes\VBSFile\Shell\Run the VBS in Sandbox with parameters" /f
Reg.exe delete "HKLM\SOFTWARE\Classes\exefile\shell\Run the EXE in Sandbox" /f
Reg.exe delete "HKLM\SOFTWARE\Classes\Msi.Package\shell\Run the MSI in Sandbox" /f

Baptiste a dit…

Thank you so much !!!
The command work perfectly. In fact i have try to uninstall-it myself in the regedit but i have forgotten some part of this.
Thanks and happy Christmas !

Anonyme a dit…

Hello,
I can't find the script "Add_Sandbox_ContextMenu.ps1" to install it.
On github.com, the download link doesn't contain it.
Thanks for some helps,

Damien Van Robaeys a dit…

Sorry i didn't have a notification for the comment.
On Github there are two files
- Add_structure.ps1: to create context menus
- Remove_structure: to remove them

Anonyme a dit…

Hello,
The Run-in-Sandbox-master does NOT contain Add_Structure.ps1, Remove_Structure.ps1 on github. The files are deleted.
How to install/uninstall without, or just bad timeing i am asking for because of work in progress?
Greetz!

Unknown a dit…

Ditto - the Add_structure script files are NOT in the GitHub repository

Anonyme a dit…

I would also like the add and remove scripts that are missing!

Accueil item

Award

Learn KQL in one month

Sponsors

You want to support me ?

Mes articles en français

Books in French


Stats