MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / HandleCommandLine

Function HandleCommandLine

WinArkSvc/WinArkSvc.cpp:262–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262int HandleCommandLine(int argc, const char* argv[]) {
263 if (!IsRunningElevated()) {
264 printf("You must run elevated to configure the service.\n");
265 return 1;
266 }
267
268 if (!_stricmp(argv[1], "install") || !_stricmp(argv[1], "/install")
269 ||!_stricmp(argv[1],"-install")) {
270 bool start = argc > 2 && _stricmp(argv[2], "start") == 0;
271 auto error = InstallService();
272 if (error == 0 && start)
273 return StartWinArkService();
274 return error;
275 }
276 if (!_stricmp(argv[1], "uninstall")||!_stricmp(argv[1],"-uninstall")
277 ||!_stricmp(argv[1],"/uinstall")){
278 return UninstallService();
279 }
280 if (!_stricmp(argv[1], "start")||!_stricmp(argv[1],"-start")) {
281 return StartWinArkService();
282 }
283 if (!_stricmp(argv[1], "stop")|| !_stricmp(argv[1], "-stop")) {
284 return StopService();
285 }
286 return 0;
287}
288
289int InstallService() {
290 SC_HANDLE hScm = ::OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);

Callers 1

mainFunction · 0.85

Calls 5

IsRunningElevatedFunction · 0.85
InstallServiceFunction · 0.85
StartWinArkServiceFunction · 0.85
UninstallServiceFunction · 0.85
StopServiceFunction · 0.85

Tested by

no test coverage detected