Skip to content

Commit

Permalink
InstallHelper: optionally suppress message boxes
Browse files Browse the repository at this point in the history
Add optional command-line parameter to suppress message
box in case the installation requires reboot or aborted.
This supports use case when the UsbDk is installed along
with other product and restart is required regardless
installation status of UsbDk. When installation helper
runs with -in or -iN, the message boxes are suppressed.

Signed-off-by: Yuri Benditovich <[email protected]>
  • Loading branch information
ybendito authored and YanVugenfirer committed Apr 15, 2019
1 parent 46c80ba commit 4c33964
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions UsbDkInstHelper/UsbDkInstHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

using namespace std;

static BOOL suppressInstallMessageBox = FALSE;

static int Controller_InstallDriver()
{
//Clean up any previous versions before reinstalling
Expand All @@ -40,14 +42,28 @@ static int Controller_InstallDriver()
case InstallFailure:
return 1;
case InstallAborted:
MessageBox(NULL,
TEXT("Failed to start the driver on the system, installation aborted!\nPlease make sure you are installing a signed version of UsbDk or else try to disable \"driver signature enforcement\" on the system"),
TEXT("UsbDk Runtime Libraries Installer"), MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_SYSTEMMODAL);
if (!suppressInstallMessageBox)
{
MessageBox(NULL,
TEXT("Failed to start the driver on the system, installation aborted!\nPlease make sure you are installing a signed version of UsbDk or else try to disable \"driver signature enforcement\" on the system"),
TEXT("UsbDk Runtime Libraries Installer"), MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_SYSTEMMODAL);
}
else
{
OutputDebugString(TEXT("UsbDkInstHelper: Installation aborted"));
}
return 4;
case InstallSuccessNeedReboot:
MessageBox(NULL,
TEXT("Please restart your computer to complete the installation"),
TEXT("UsbDk Runtime Libraries Installer"), MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_SYSTEMMODAL);
if (!suppressInstallMessageBox)
{
MessageBox(NULL,
TEXT("Please restart your computer to complete the installation"),
TEXT("UsbDk Runtime Libraries Installer"), MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_SYSTEMMODAL);
}
else
{
OutputDebugString(TEXT("UsbDkInstHelper: reboot required to complete the installation"));
}
return 0;
default:
assert(0);
Expand Down Expand Up @@ -101,6 +117,10 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi

if (lpCmdLine[0] == 'i')
{
if (lpCmdLine[1] == 'n' || lpCmdLine[1] == 'N')
{
suppressInstallMessageBox = TRUE;
}
OutputDebugString(TEXT("UsbDkInstHelper: Install"));
return Controller_InstallDriver();
}
Expand Down

0 comments on commit 4c33964

Please sign in to comment.