Use nssm_imagepath().
[nssm.git] / service.cpp
index 617cad1..6a3907e 100644 (file)
@@ -1126,7 +1126,7 @@ int install_service(nssm_service_t *service) {
   }\r
 \r
   /* Get path of this program */\r
-  GetModuleFileName(0, service->image, _countof(service->image));\r
+  _sntprintf_s(service->image, _countof(service->image), _TRUNCATE, _T("%s"), nssm_imagepath());\r
 \r
   /* Create the service - settings will be changed in edit_service() */\r
   service->handle = CreateService(services, service->name, service->name, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, service->image, 0, 0, 0, 0, 0);\r