Skip to content

Commit

Permalink
Allow possibility to extract ZIP in Sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
damienvanrobaeys authored Apr 23, 2020
1 parent eb9eb35 commit c8c313a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 11 deletions.
50 changes: 39 additions & 11 deletions Add_Structure.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ $Destination_folder = $ProgData
copy-item $Sources $Destination_folder -force -recurse
$Sandbox_Icon = "$Destination_folder\Run_in_Sandbox\sandbox.ico"

$List_Drive = get-psdrive | where {$_.Name -eq "HKCR_SD"}
If($List_Drive -ne $null){Remove-PSDrive $List_Drive}
New-PSDrive -PSProvider registry -Root HKEY_CLASSES_ROOT -Name HKCR_SD


# RUN ON PS1
$PS1_Shell_Registry_Key = "HKCR_SD:\Microsoft.PowerShellScript.1\Shell"
$PS1_Basic_Run = "Run the PS1 in Sandbox"
$PS1_Parameter_Run = "Run the PS1 in Sandbox with parameters"
$ContextMenu_Basic_PS1 = "$PS1_Shell_Registry_Key\$PS1_Basic_Run"
$ContextMenu_Parameters_PS1 = "$PS1_Shell_Registry_Key\$PS1_Parameter_Run"
$List_Drive = get-psdrive | where {$_.Name -eq "HKCR_SD"}
If($List_Drive -ne $null){Remove-PSDrive $List_Drive}
New-PSDrive -PSProvider registry -Root HKEY_CLASSES_ROOT -Name HKCR_SD

New-Item -Path $PS1_Shell_Registry_Key -Name $PS1_Basic_Run -force
New-Item -Path $PS1_Shell_Registry_Key -Name $PS1_Parameter_Run -force
New-Item -Path $ContextMenu_Basic_PS1 -Name "Command" -force
Expand All @@ -41,6 +44,7 @@ $VBS_Basic_Run = "Run the VBS in Sandbox"
$VBS_Parameter_Run = "Run the VBS in Sandbox with parameters"
$ContextMenu_Basic_VBS = "$VBS_Shell_Registry_Key\$VBS_Basic_Run"
$ContextMenu_Parameters_VBS = "$VBS_Shell_Registry_Key\$VBS_Parameter_Run"

New-Item -Path $VBS_Shell_Registry_Key -Name $VBS_Basic_Run -force
New-Item -Path $VBS_Shell_Registry_Key -Name $VBS_Parameter_Run -force
New-Item -Path $ContextMenu_Basic_VBS -Name "Command" -force
Expand All @@ -59,6 +63,7 @@ New-ItemProperty -Path $ContextMenu_Parameters_VBS -Name "icon" -PropertyType St
$EXE_Shell_Registry_Key = "HKCR_SD:\exefile\Shell"
$EXE_Basic_Run = "Run the EXE in Sandbox"
$ContextMenu_Basic_EXE = "$EXE_Shell_Registry_Key\$EXE_Basic_Run"

New-Item -Path $EXE_Shell_Registry_Key -Name $EXE_Basic_Run -force
New-Item -Path $ContextMenu_Basic_EXE -Name "Command" -force
# Add Sandbox Icons
Expand All @@ -72,6 +77,7 @@ Set-Item -Path "$ContextMenu_Basic_EXE\command" -Value $Command_For_EXE -force
$MSI_Shell_Registry_Key = "HKCR_SD:\Msi.Package\Shell"
$MSI_Basic_Run = "Run the MSI in Sandbox"
$ContextMenu_Basic_MSI = "$MSI_Shell_Registry_Key\$MSI_Basic_Run"

New-Item -Path $MSI_Shell_Registry_Key -Name $MSI_Basic_Run -force
New-Item -Path $ContextMenu_Basic_MSI -Name "Command" -force
# Add Sandbox Icons
Expand All @@ -81,12 +87,34 @@ $Command_For_MSI = 'C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.e
Set-Item -Path "$ContextMenu_Basic_MSI\command" -Value $Command_For_MSI -force


# RUN ON ZIP
$ZIP_Shell_Registry_Key = "HKCR_SD:\CompressedFolder\Shell"
$ZIP_Basic_Run = "Extract the ZIP in Sandbox"
$ContextMenu_Basic_ZIP = "$ZIP_Shell_Registry_Key\$ZiP_Basic_Run"









New-Item -Path $ZIP_Shell_Registry_Key -Name $ZiP_Basic_Run -force
New-Item -Path $ContextMenu_Basic_ZIP -Name "Command" -force
# Add Sandbox Icons
New-ItemProperty -Path $ContextMenu_Basic_ZIP -Name "icon" -PropertyType String -Value $Sandbox_Icon
$Command_For_ZIP = 'C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -executionpolicy bypass -sta -file C:\\ProgramData\\Run_in_Sandbox\\RunInSandbox.ps1 -NoExit -Command Set-Location -Type ZIP -LiteralPath "%V" -ScriptPath "%V"'
# Set the command path
Set-Item -Path "$ContextMenu_Basic_ZIP\command" -Value $Command_For_ZIP -force


# RUN ON ZIP if WinRAR is installed
If(test-path "HKCR_SD:\WinRAR.ZIP\Shell")
{
$ZIP_WinRAR_Shell_Registry_Key = "HKCR_SD:\WinRAR.ZIP\Shell"
$ZIP_WinRAR_Basic_Run = "Extract the ZIP in Sandbox"
$ContextMenu_Basic_ZIP_RAR = "$ZIP_WinRAR_Shell_Registry_Key\$ZIP_WinRAR_Basic_Run"

New-Item -Path $ZIP_WinRAR_Shell_Registry_Key -Name $ZIP_WinRAR_Basic_Run -force
New-Item -Path $ContextMenu_Basic_ZIP_RAR -Name "Command" -force
# Add Sandbox Icons
New-ItemProperty -Path $ContextMenu_Basic_ZIP_RAR -Name "icon" -PropertyType String -Value $Sandbox_Icon
$Command_For_ZIP = 'C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -executionpolicy bypass -sta -file C:\\ProgramData\\Run_in_Sandbox\\RunInSandbox.ps1 -NoExit -Command Set-Location -Type ZIP -LiteralPath "%V" -ScriptPath "%V"'
# Set the command path
Set-Item -Path "$ContextMenu_Basic_ZIP_RAR\command" -Value $Command_For_ZIP -force
}

If($List_Drive -ne $null){Remove-PSDrive $List_Drive}
13 changes: 13 additions & 0 deletions Remove_Structure.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,17 @@ $MSI_Shell_Registry_Key = "HKCR_SD:\Msi.Package\Shell"
$MSI_Basic_Run = "Run the MSI in Sandbox"
Remove-Item -Path "$MSI_Shell_Registry_Key\$MSI_Basic_Run" -Recurse

# RUN ON ZIP
$ZIP_Shell_Registry_Key = "HKCR_SD:\CompressedFolder\Shell"
$ZIP_Basic_Run = "Extract the ZIP in Sandbox"
Remove-Item -Path "$ZIP_Shell_Registry_Key\$ZIP_Basic_Run" -Recurse

# RUN ON ZIP if WinRAR is installed
If(test-path "HKCR_SD:\WinRAR.ZIP\Shell")
{
$ZIP_WinRAR_Shell_Registry_Key = "HKCR_SD:\WinRAR.ZIP\Shell"
$ZIP_WinRAR_Basic_Run = "Extract the ZIP in Sandbox"
Remove-Item -Path "$ZIP_WinRAR_Shell_Registry_Key\$ZIP_WinRAR_Basic_Run" -Recurse
}

If($List_Drive -ne $null){Remove-PSDrive $List_Drive}

0 comments on commit c8c313a

Please sign in to comment.