mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-02-10 18:05:16 +08:00
[win] updatesvc: pass cmd line arguments on restart
This commit is contained in:
@ -175,11 +175,15 @@ auto restartService()->void
|
||||
return;
|
||||
}
|
||||
|
||||
wstring args = NS_Utils::cmdArgsAsString();
|
||||
if (!args.empty())
|
||||
args.insert(0, 1, L' ');
|
||||
|
||||
std::list<wstring> batch = {
|
||||
L"@chcp 65001>nul",
|
||||
L"@echo off",
|
||||
wstring(L"NET STOP ") + L"\"" + TEXT(VER_PRODUCTNAME_STR) + L"\"",
|
||||
wstring(L"NET START ") + L"\"" + TEXT(VER_PRODUCTNAME_STR) + L"\"",
|
||||
wstring(L"SC STOP ") + L"\"" + TEXT(VER_PRODUCTNAME_STR) + L"\"",
|
||||
wstring(L"SC START ") + L"\"" + TEXT(VER_PRODUCTNAME_STR) + L"\"" + args,
|
||||
L"del /F /Q \"%~dp0~updatesvc.exe\"",
|
||||
L"exit"
|
||||
};
|
||||
|
||||
@ -153,6 +153,17 @@ namespace NS_Utils
|
||||
return L"";
|
||||
}
|
||||
|
||||
wstring cmdArgsAsString()
|
||||
{
|
||||
if (cmd_args.empty())
|
||||
return L"";
|
||||
wstring args = cmd_args[0];
|
||||
for (size_t i = 1; i < cmd_args.size(); ++i) {
|
||||
args += L" " + cmd_args[i];
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
wstring GetLastErrorAsString()
|
||||
{
|
||||
DWORD errID = ::GetLastError();
|
||||
|
||||
@ -53,6 +53,7 @@ bool isRunAsApp();
|
||||
void parseCmdArgs(int argc, wchar_t *argv[]);
|
||||
bool cmdArgContains(const wstring ¶m);
|
||||
wstring cmdArgValue(const wstring ¶m);
|
||||
wstring cmdArgsAsString();
|
||||
wstring GetLastErrorAsString();
|
||||
int ShowMessage(wstring str, bool showError = false);
|
||||
wstring GetAppLanguage();
|
||||
|
||||
Reference in New Issue
Block a user