summaryrefslogtreecommitdiff
path: root/windows/ZeroTierOne/ServiceInstaller.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@zerotier.com>2014-02-27 16:28:55 -0800
committerAdam Ierymenko <adam.ierymenko@zerotier.com>2014-02-27 16:28:55 -0800
commit9d05897f7a3d06f5504b3bb75dd7e822e5faebf9 (patch)
tree94b4fca19138ef431d547fa9cbee4f429c7b7de9 /windows/ZeroTierOne/ServiceInstaller.cpp
parentcbeb9c523644a49abb679bc4c97859238d28da2d (diff)
downloadinfinitytier-9d05897f7a3d06f5504b3bb75dd7e822e5faebf9.tar.gz
infinitytier-9d05897f7a3d06f5504b3bb75dd7e822e5faebf9.zip
Windows service works now!
Diffstat (limited to 'windows/ZeroTierOne/ServiceInstaller.cpp')
-rw-r--r--windows/ZeroTierOne/ServiceInstaller.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/windows/ZeroTierOne/ServiceInstaller.cpp b/windows/ZeroTierOne/ServiceInstaller.cpp
index 5945ecdf..d302d9f6 100644
--- a/windows/ZeroTierOne/ServiceInstaller.cpp
+++ b/windows/ZeroTierOne/ServiceInstaller.cpp
@@ -50,16 +50,19 @@ std::string InstallService(PSTR pszServiceName,
PSTR pszPassword)
{
std::string ret;
- char szPath[MAX_PATH];
+ char szPathTmp[MAX_PATH],szPath[MAX_PATH];
SC_HANDLE schSCManager = NULL;
SC_HANDLE schService = NULL;
- if (GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)) == 0)
+ if (GetModuleFileName(NULL, szPathTmp, ARRAYSIZE(szPath)) == 0)
{
ret = "GetModuleFileName failed, unable to get path to self";
goto Cleanup;
}
+ // Quote path in case it contains spaces
+ _snprintf_s(szPath,sizeof(szPath),"\"%s\"",szPathTmp);
+
// Open the local default service control manager database
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT |
SC_MANAGER_CREATE_SERVICE);