[win] updatesvc: pass cmd line arguments on restart

This commit is contained in:
SimplestStudio
2025-06-16 17:53:36 +03:00
parent 83f223e067
commit 0ed868994f
3 changed files with 18 additions and 2 deletions

View File

@ -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"
};

View File

@ -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();

View File

@ -53,6 +53,7 @@ bool isRunAsApp();
void parseCmdArgs(int argc, wchar_t *argv[]);
bool cmdArgContains(const wstring &param);
wstring cmdArgValue(const wstring &param);
wstring cmdArgsAsString();
wstring GetLastErrorAsString();
int ShowMessage(wstring str, bool showError = false);
wstring GetAppLanguage();