-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Expected behavior
I would like to start an application (based on POCO) as Windows service. This works fine, until I use required parameters.
void RRCApplication::defineOptions(OptionSet& options)
{
ServerApplication::defineOptions(options);
options.addOption(
Option("cfg", "f", "Load configuration data from an XML file. E.g.: /cfg=\"C:\\RRC-M\\cfg\\app.xml\"")
.required(true)
.repeatable(false)
.argument("file")
.callback(OptionCallback<RRCApplication>(this, &RRCApplication::handleConfig)));
}
Actual behavior
When starting the service, application fails on error 78. It seems, the arguments are not passed.
I attached debugger to application when starting and size of args is 1, so no params are passed:
\poco-1.8.0.1-all\Util\src\ServerApplication.cpp, line 179:
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
std::vector<std::string> args;
for (DWORD i = 0; i < argc; ++i) // argc == 1 (name of executable)
{
std::string arg;
Poco::UnicodeConverter::toUTF8(argv[i], arg);
args.push_back(arg);
}
app.init(args);
#else
I have registered the service as
sc create MySVC binpath= "C:\MySVC\MySVC.exe /cfg=\"C:\MySVC\cfg\app.xml\"" displayname= "MySVC" start= auto
In properties of the service (in Windows service list using mmc), I can see the path:
C:\MySVC\MySVC.exe /cfg="C:\MySVC\cfg\app.xml"
However, the parameter cfg is obviously not passed. When starting application from command line, everything is OK.
The question is, how to pass params using service?
Thank you!
POCO version
1.8.0.1
Compiler and version
VC14
Operating system and version
Windows 7
Other relevant information
Server application as service