diff --git a/admin/win/tools/NCMsiHelper/NCMsiHelper.cpp b/admin/win/tools/NCMsiHelper/NCMsiHelper.cpp index 1a167ebbf..9a8eb6a0f 100644 --- a/admin/win/tools/NCMsiHelper/NCMsiHelper.cpp +++ b/admin/win/tools/NCMsiHelper/NCMsiHelper.cpp @@ -49,7 +49,6 @@ HRESULT NCMSIHELPER_API DoExecNsisUninstaller(int argc, LPWSTR *argv) // Can't wait for the process because Uninstall.exe (opposed to Setup.exe) immediately returns, so we'll sleep a bit. Utility::waitForNsisUninstaller(appShortName); - Utility::removeUsersFromKeychain(appShortName); LogResult(S_OK, "Removing the NSIS uninstaller."); @@ -71,6 +70,8 @@ HRESULT NCMSIHELPER_API DoRemoveNavigationPaneEntries(int argc, LPWSTR *argv) const auto appName = std::wstring(argv[0]); + Utility::removeUsersFromKeychain(appName); + if (appName.empty()) { return HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER); } diff --git a/admin/win/tools/NCToolsShared/utility_win.cpp b/admin/win/tools/NCToolsShared/utility_win.cpp index b5fd85b9f..63b6dbca1 100644 --- a/admin/win/tools/NCToolsShared/utility_win.cpp +++ b/admin/win/tools/NCToolsShared/utility_win.cpp @@ -477,10 +477,12 @@ bool Utility::copy_dir_recursive(std::wstring from_dir, std::wstring to_dir, cop void Utility::removeUsersFromKeychain(const std::wstring &appName) { + // https://learn.microsoft.com/en-us/windows/win32/api/wincred/nf-wincred-creddeletew + // https://github.com/frankosterfeld/qtkeychain/blob/181103549bcda0e4c38988255af64930cfa64ed7/qtkeychain/keychain_win.cpp if (!CredDeleteW(appName.c_str(), CRED_TYPE_GENERIC, 0)) { switch(GetLastError()) { case ERROR_NOT_FOUND: - // Password entry not found" + // Password entry not found break; default: // Could not decrypt data