diff --git a/WeaselServer/WeaselServer.cpp b/WeaselServer/WeaselServer.cpp index eafe0120b..edeff0915 100644 --- a/WeaselServer/WeaselServer.cpp +++ b/WeaselServer/WeaselServer.cpp @@ -92,14 +92,24 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lp // command line option /q stops the running server bool quit = !wcscmp(L"/q", lpstrCmdLine) || !wcscmp(L"/quit", lpstrCmdLine); // restart if already running - if(quit) { weasel::Client client; if (client.Connect()) // try to connect to running server { client.ShutdownServer(); + if (quit) + return 0; + int retry = 0; + while (client.Connect() && retry < 10) { + client.ShutdownServer(); + retry++; + Sleep(50); + } + if (retry >= 10) + return 0; } - return 0; + else if (quit) + return 0; } bool check_updates = !wcscmp(L"/update", lpstrCmdLine); diff --git a/WeaselTSF/LanguageBar.cpp b/WeaselTSF/LanguageBar.cpp index fcc4efcb2..9b252e8d1 100644 --- a/WeaselTSF/LanguageBar.cpp +++ b/WeaselTSF/LanguageBar.cpp @@ -303,8 +303,6 @@ void WeaselTSF::_HandleLangBarMenuSelect(UINT wID) { std::wstring dir(szValue); std::thread th([dir]() { - ShellExecuteW(NULL, L"open", (dir + L"\\stop_service.bat").c_str(), NULL, dir.c_str(), SW_HIDE); - Sleep(100); ShellExecuteW(NULL, L"open", (dir + L"\\start_service.bat").c_str(), NULL, dir.c_str(), SW_HIDE); }); th.detach();