Use the absolute path and UrlCreateFromPath to create the file:/// url, pass that InstallService url.
Meanwhile, your XML seems to have an error.
WCHAR szURL[MAX_PATH] = L""; DWORD cchURL = ARRAYSIZE(szURL); hr = ::UrlCreateFromPath(argv[2], szURL, &cchURL, 0); if (SUCCEEDED(hr)) { hr = spManager->InstallService(argv[2], &spService); // Now we can set it as the default. if (SUCCEEDED(hr)) { hr = spService->SetDefault(TRUE, NULL); if (hr == OS_E_CANCELLED) { hr = E_ACCESSDENIED; // by the user! } } }
source share