Skip to content

Commit 03ae70e

Browse files
committed
Add update/reboot and update/shutdown menu options
1 parent d0580e7 commit 03ae70e

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

ProcessHacker/actions.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,33 @@ BOOLEAN PhUiRestartComputer(
911911
}
912912
}
913913
break;
914+
case PH_POWERACTION_TYPE_UPDATE:
915+
{
916+
if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage(
917+
WindowHandle,
918+
L"update and restart",
919+
L"the computer",
920+
NULL,
921+
FALSE
922+
))
923+
{
924+
ULONG status;
925+
926+
status = InitiateShutdown(
927+
NULL,
928+
NULL,
929+
0,
930+
SHUTDOWN_RESTART | SHUTDOWN_INSTALL_UPDATES,
931+
SHTDN_REASON_FLAG_PLANNED
932+
);
933+
934+
if (status == ERROR_SUCCESS)
935+
return TRUE;
936+
937+
PhShowStatus(WindowHandle, L"Unable to restart the computer.", 0, status);
938+
}
939+
}
940+
break;
914941
}
915942

916943
return FALSE;
@@ -1026,6 +1053,33 @@ BOOLEAN PhUiShutdownComputer(
10261053
}
10271054
}
10281055
break;
1056+
case PH_POWERACTION_TYPE_UPDATE:
1057+
{
1058+
if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage(
1059+
WindowHandle,
1060+
L"update and shutdown",
1061+
L"the computer",
1062+
NULL,
1063+
FALSE
1064+
))
1065+
{
1066+
ULONG status;
1067+
1068+
status = InitiateShutdown(
1069+
NULL,
1070+
NULL,
1071+
0,
1072+
SHUTDOWN_POWEROFF | SHUTDOWN_INSTALL_UPDATES,
1073+
SHTDN_REASON_FLAG_PLANNED
1074+
);
1075+
1076+
if (status == ERROR_SUCCESS)
1077+
return TRUE;
1078+
1079+
PhShowStatus(WindowHandle, L"Unable to shut down the computer.", 0, status);
1080+
}
1081+
}
1082+
break;
10291083
}
10301084

10311085
return FALSE;

ProcessHacker/include/actions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ typedef enum _PH_POWERACTION_TYPE
8080
PH_POWERACTION_TYPE_CRITICAL,
8181
PH_POWERACTION_TYPE_ADVANCEDBOOT,
8282
PH_POWERACTION_TYPE_FIRMWAREBOOT,
83+
PH_POWERACTION_TYPE_UPDATE,
8384
PH_POWERACTION_TYPE_MAXIMUM
8485
} PH_POWERACTION_TYPE;
8586

ProcessHacker/mainwnd.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,6 +2191,12 @@ BOOLEAN PhMwpExecuteComputerCommand(
21912191
case ID_COMPUTER_SHUTDOWN_CRITICAL:
21922192
PhUiShutdownComputer(WindowHandle, PH_POWERACTION_TYPE_CRITICAL, 0);
21932193
return TRUE;
2194+
case ID_COMPUTER_RESTART_UPDATE:
2195+
PhUiRestartComputer(WindowHandle, PH_POWERACTION_TYPE_UPDATE, 0);
2196+
return TRUE;
2197+
case ID_COMPUTER_SHUTDOWN_UPDATE:
2198+
PhUiShutdownComputer(WindowHandle, PH_POWERACTION_TYPE_UPDATE, 0);
2199+
return TRUE;
21942200
}
21952201

21962202
return FALSE;
@@ -2263,6 +2269,9 @@ PPH_EMENU PhpCreateComputerMenu(
22632269
PhInsertEMenuItem(menuItem, PhCreateEMenuItem(0, ID_COMPUTER_SLEEP, L"&Sleep", NULL, NULL), ULONG_MAX);
22642270
PhInsertEMenuItem(menuItem, PhCreateEMenuItem(0, ID_COMPUTER_HIBERNATE, L"&Hibernate", NULL, NULL), ULONG_MAX);
22652271
PhInsertEMenuItem(menuItem, PhCreateEMenuSeparator(), ULONG_MAX);
2272+
PhInsertEMenuItem(menuItem, PhCreateEMenuItem(0, ID_COMPUTER_RESTART_UPDATE, L"Update and restart", NULL, NULL), ULONG_MAX);
2273+
PhInsertEMenuItem(menuItem, PhCreateEMenuItem(0, ID_COMPUTER_SHUTDOWN_UPDATE, L"Update and shut down", NULL, NULL), ULONG_MAX);
2274+
PhInsertEMenuItem(menuItem, PhCreateEMenuSeparator(), ULONG_MAX);
22662275
PhInsertEMenuItem(menuItem, PhCreateEMenuItem(0, ID_COMPUTER_RESTART, L"R&estart", NULL, NULL), ULONG_MAX);
22672276
PhInsertEMenuItem(menuItem, PhCreateEMenuItem(0, ID_COMPUTER_RESTARTADVOPTIONS, L"Restart to advanced options", NULL, NULL), ULONG_MAX);
22682277
PhInsertEMenuItem(menuItem, PhCreateEMenuItem(0, ID_COMPUTER_RESTARTBOOTOPTIONS, L"Restart to boot options", NULL, NULL), ULONG_MAX);

0 commit comments

Comments
 (0)