Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CleanAfterReboot #4222

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [1.14.8 / 5.69.8] - 2024-09-??

### Added
- added a menu action to clean boxes after the machine reboot

### Changed
- allowed users to import/export boxes with .zip files.
- allowed users to import/export boxes with .zip files

### Fixed
- fixed a cert issue
Expand Down
15 changes: 10 additions & 5 deletions SandboxiePlus/SandMan/SandMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ CSandMan::CSandMan(QWidget *parent)
}

connect(CSymbolProvider::Instance(), SIGNAL(StatusChanged(const QString&)), this, SLOT(OnSymbolStatus(const QString&)));

//qApp->setWindowIcon(GetIcon("IconEmptyDC", false));
}

Expand Down Expand Up @@ -2528,15 +2527,21 @@ void CSandMan::OnStatusChanged()
}

UpdateForceUSB();

if (theConf->GetBool("Options/CleanUpOnStart", false)) {
theAPI->UpdateProcesses(0, ShowAllSessions());
bool bAutoRun = QApplication::arguments().contains("-autorun");
if(bAutoRun) {
foreach(
const CSandBoxPtr &pBox, AllBoxes) {
if (pBox->GetBool("CleanAfterReboot"))
DeleteBoxContent(pBox, eAuto, true);
}
}
if (theConf->GetBool("Options/CleanUpOnStart", false)) {

//
// clean up Auto Delete boxes after reboot
//

theAPI->UpdateProcesses(0, ShowAllSessions());

foreach(const CSandBoxPtr & pBox, AllBoxes) {
if (pBox->GetActiveProcessCount() == 0)
OnBoxClosed(pBox);
Expand Down
24 changes: 24 additions & 0 deletions SandboxiePlus/SandMan/Views/SbieView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ void CSbieView::CreateMenu()
m_pMenuDuplicate = m_pMenuTools->addAction(CSandMan::GetIcon("Duplicate"), tr("Duplicate Box Config"), this, SLOT(OnSandBoxAction()));
m_pMenuExport = m_pMenuTools->addAction(CSandMan::GetIcon("PackBox"), tr("Export Box"), this, SLOT(OnSandBoxAction()));
m_pMenuExport->setEnabled(CArchive::IsInit());
m_pRebootClean = m_pMenuTools->addAction(CSandMan::GetIcon("Maintenance"),tr("Completely clean after reboot"),this,SLOT(OnSandBoxAction()));

m_pMenuRename = m_pMenuBox->addAction(CSandMan::GetIcon("Rename"), tr("Rename Sandbox"), this, SLOT(OnSandBoxAction()));
m_pMenuMoveTo = m_pMenuBox->addMenu(CSandMan::GetIcon("Group"), tr("Move Sandbox"));
Expand Down Expand Up @@ -344,6 +345,8 @@ void CSbieView::CreateOldMenu()
m_pMenuDuplicate = m_pMenuTools->addAction(CSandMan::GetIcon("Duplicate"), tr("Duplicate Sandbox Config"), this, SLOT(OnSandBoxAction()));
m_pMenuExport = m_pMenuTools->addAction(CSandMan::GetIcon("PackBox"), tr("Export Sandbox"), this, SLOT(OnSandBoxAction()));
m_pMenuExport->setEnabled(CArchive::IsInit());
m_pRebootClean = m_pMenuTools->addAction(CSandMan::GetIcon("Maintenance"),tr("Completely clean after reboot"),this,SLOT(OnSandBoxAction()));


m_pMenuTools->addSeparator();
m_pMenuRefresh = m_pMenuTools->addAction(CSandMan::GetIcon("Refresh"), tr("Refresh Info"), this, SLOT(OnSandBoxAction()));
Expand Down Expand Up @@ -1386,6 +1389,27 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB

Results.append(Status);
}
else if (Action == m_pRebootClean)
{
CSandBoxPtr pBox=SandBoxes.first();
auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
QString fileRoot=pBoxEx->GetFileRoot();
if(QMessageBox::question(this, tr("Sandboxie-Plus"),
tr("Do you want to make the box cleaned after machine reboot?"),
Jkkoi marked this conversation as resolved.
Show resolved Hide resolved
QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes){
if(QMessageBox::question(this, tr("Sandboxie-Plus"),
tr("Do you want to use Windows Delecting Feature(MoveFileEx)?Or we'll delete the box when Sandman.exe called by userinit.exe."),
Jkkoi marked this conversation as resolved.
Show resolved Hide resolved
QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes){
if(MoveFileExW(fileRoot.toStdString().c_str(),NULL,4)==0){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MoveFileExW->MoveFileExA

QMessageBox::warning(this, tr("Sandboxie-Plus"),
tr("The operation failed,please make sure that Sandman has admin privliage.")
Jkkoi marked this conversation as resolved.
Show resolved Hide resolved
, QMessageBox::Yes, 0);
}
}
else{
pBox->SetBool("CleanAfterReboot",true);
}
}
else if (Action == m_pMenuExport)
{
CSandBoxPtr pBox = SandBoxes.first();
Expand Down
1 change: 1 addition & 0 deletions SandboxiePlus/SandMan/Views/SbieView.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ private slots:
QMenu* m_pMenuTools;
QAction* m_pMenuDuplicate;
QAction* m_pMenuExport;
QAction* m_pRebootClean;
QAction* m_pMenuMoveUp;
//QAction* m_pMenuMoveBy;
QAction* m_pMenuMoveDown;
Expand Down