diff --git a/src/wx/winsparkle-wrapper.cpp b/src/wx/winsparkle-wrapper.cpp index 3e0f233e..fb10cb24 100644 --- a/src/wx/winsparkle-wrapper.cpp +++ b/src/wx/winsparkle-wrapper.cpp @@ -1,5 +1,7 @@ +#include #include +#include #include "wxvbam.h" #include "winsparkle-wrapper.h" #include "wx/msw/private.h" @@ -47,7 +49,17 @@ WinSparkleDllWrapper::~WinSparkleDllWrapper() { delete winsparkle_dll; - wxRemoveFile(temp_file_name); + // Wait for the program to exit and release the DLL before deleting the temp file, otherwise access is denied. + const auto shell_cmd = std::string("ping -n 3 127.0.0.1 > nul&set _file=") + temp_file_name + "&call del %^_file%"; + + const char* cmd[]{ + "cmd.exe", + "/c", + shell_cmd.c_str(), + NULL + }; + + wxExecute(cmd, wxEXEC_ASYNC | wxEXEC_HIDE_CONSOLE); } void win_sparkle_init()