diff --git a/SandboxiePlus/SandMan/Forms/OptionsWindow.ui b/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
index c42456f5..c4f2beb9 100644
--- a/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
+++ b/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
@@ -6,7 +6,7 @@
0
0
- 715
+ 785
526
@@ -3732,7 +3732,7 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
- 4
+ 1
@@ -3849,8 +3849,8 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
3
- -
-
+
-
+
0
@@ -3863,11 +3863,21 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
23
+
+ Remove
+
+
+
+ -
+
- This command will be run before the box content will be deleted
+ These commands are run UNBOXED just before the box content is deleted
- Run Command
+ On File Recovery
+
+
+ Qt::AlignCenter
@@ -3890,7 +3900,46 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
- -
+
-
+
+
+ These commands are executed only when a box is initialized. To make them run again, the box content must be deleted.
+
+
+ On Box Init
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ These commands are run UNBOXED just before the box content is deleted
+
+
+ On Delete Content
+
+
+ Qt::AlignCenter
+
+
+
+ -
true
@@ -3913,26 +3962,29 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
-
-
+
- These commands are run UNBOXED just before the box content is deleted
+ This command runs after all processes in the sandbox have finished.
- On File Recovery
+ On Box Terminate
Qt::AlignCenter
- -
-
+
-
+
- Show Templates
+ Here you can specify actions to be executed automatically on various box events.
+
+
+ true
- -
+
-
@@ -3954,80 +4006,6 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 23
-
-
-
- Remove
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- These commands are executed only when a box is initialized. To make them run again, the box content must be deleted.
-
-
- On Box Init
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
- Here you can specify actions to be executed automatically on various box events.
-
-
- true
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 23
-
-
-
- Run Command
-
-
-
-
@@ -4041,6 +4019,35 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 23
+
+
+
+ This command will be run before the box content will be deleted
+
+
+ Run Command
+
+
+
+ -
+
+
+ Show Templates
+
+
+
-
@@ -4060,16 +4067,41 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
- -
-
-
- These commands are run UNBOXED just before the box content is deleted
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 23
+
- On Delete Content
+ Run Command
-
- Qt::AlignCenter
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 23
+
+
+
+ Run Command
@@ -4473,8 +4505,8 @@ instead of "*".
0
0
- 98
- 28
+ 92
+ 16
diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp
index 8da08bff..b50ca10c 100644
--- a/SandboxiePlus/SandMan/SandMan.cpp
+++ b/SandboxiePlus/SandMan/SandMan.cpp
@@ -2258,6 +2258,13 @@ void CSandMan::OnStartMenuChanged()
void CSandMan::OnBoxClosed(const CSandBoxPtr& pBox)
{
+ foreach(const QString & Value, pBox->GetTextList("OnBoxTerminate", true, false, true)) {
+ QString Value2 = pBox->Expand(Value);
+ CSbieProgressPtr pProgress = CSbieUtils::RunCommand(Value2, true);
+ if (!pProgress.isNull()) {
+ AddAsyncOp(pProgress, true, tr("Executing OnBoxTerminate: %1").arg(Value2));
+ }
+ }
if (!pBox->GetBool("NeverDelete", false))
{
if (pBox->GetBool("AutoDelete", false))
@@ -4452,4 +4459,4 @@ void InitCertSlot()
g_MailRun = true;
g_MailThread = CreateThread(NULL, 0, MailThreadFunc, NULL, 0, NULL);
-}
\ No newline at end of file
+}
diff --git a/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp b/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp
index 67fa3b03..af225cda 100644
--- a/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp
+++ b/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp
@@ -89,6 +89,7 @@ void COptionsWindow::CreateAdvanced()
connect(ui.btnAddAutoExec, SIGNAL(clicked(bool)), this, SLOT(OnAddAutoExec()));
connect(ui.btnAddRecoveryCmd, SIGNAL(clicked(bool)), this, SLOT(OnAddRecoveryCheck()));
connect(ui.btnAddDeleteCmd, SIGNAL(clicked(bool)), this, SLOT(OnAddDeleteCmd()));
+ connect(ui.btnAddTerminateCmd, SIGNAL(clicked(bool)), this, SLOT(OnAddTerminateCmd()));
connect(ui.btnDelAuto, SIGNAL(clicked(bool)), this, SLOT(OnDelAuto()));
connect(ui.chkShowTriggersTmpl, SIGNAL(clicked(bool)), this, SLOT(OnShowTriggersTmpl()));
@@ -411,6 +412,7 @@ void COptionsWindow::SaveAdvanced()
QStringList RecoveryCheck;
QStringList DeleteCommand;
QStringList AutoExec;
+ QStringList TerminateCommand;
for (int i = 0; i < ui.treeTriggers->topLevelItemCount(); i++) {
QTreeWidgetItem* pItem = ui.treeTriggers->topLevelItem(i);
switch (pItem->data(0, Qt::UserRole).toInt())
@@ -420,6 +422,7 @@ void COptionsWindow::SaveAdvanced()
case eAutoExec: AutoExec.append(pItem->text(2)); break;
case eRecoveryCheck: RecoveryCheck.append(pItem->text(2)); break;
case eDeleteCmd: DeleteCommand.append(pItem->text(2)); break;
+ case eTerminateCmd: TerminateCommand.append(pItem->text(2)); break;
}
}
WriteTextList("StartProgram", StartProgram);
@@ -427,6 +430,7 @@ void COptionsWindow::SaveAdvanced()
WriteTextList("AutoExec", AutoExec);
WriteTextList("OnFileRecovery", RecoveryCheck);
WriteTextList("OnBoxDelete", DeleteCommand);
+ WriteTextList("OnBoxTerminate", TerminateCommand);
//
@@ -874,6 +878,9 @@ void COptionsWindow::AddTriggerItem(const QString& Value, ETriggerAction Type, c
pItem->setText(0, tr("On Delete Content"));
pItem->setText(1, tr("Run Command"));
break;
+ case eTerminateCmd:
+ pItem->setText(0, tr("On Terminate"));
+ pItem->setText(1, tr("Run Command"));
}
pItem->setText(2, Value);
pItem->setFlags(pItem->flags() | Qt::ItemIsEditable);
@@ -924,6 +931,17 @@ void COptionsWindow::OnAddDeleteCmd()
OnOptChanged();
}
+void COptionsWindow::OnAddTerminateCmd()
+{
+ QString Value = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please enter the command line to be executed"), QLineEdit::Normal);
+ if (Value.isEmpty())
+ return;
+
+ AddTriggerItem(Value, eTerminateCmd);
+ m_AdvancedChanged = true;
+ OnOptChanged();
+}
+
void COptionsWindow::OnAddRecoveryCheck()
{
QString Value = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please enter the command line to be executed"), QLineEdit::Normal);
diff --git a/SandboxiePlus/SandMan/Windows/OptionsWindow.h b/SandboxiePlus/SandMan/Windows/OptionsWindow.h
index e6d0a317..8154553e 100644
--- a/SandboxiePlus/SandMan/Windows/OptionsWindow.h
+++ b/SandboxiePlus/SandMan/Windows/OptionsWindow.h
@@ -191,6 +191,7 @@ private slots:
void OnAddAutoExec();
void OnAddRecoveryCheck();
void OnAddDeleteCmd();
+ void OnAddTerminateCmd();
void OnDelAuto();
void OnAddProcess();
@@ -334,7 +335,8 @@ public:
eOnStartSvc,
eAutoExec,
eRecoveryCheck,
- eDeleteCmd
+ eDeleteCmd,
+ eTerminateCmd
};
static QString AccessTypeToName(EAccessEntry Type);