X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fprocess.c;h=153dc67db79f7790fdd03a12cb7ed87a6179ab76;hb=3a316823b971396a428f020f401b9fe41252d98d;hp=5d78c2954b4604fc447668470e7b72a175d4f451;hpb=af9ee7ff003fb448b783ccf39347907adc239cb2;p=tinc diff --git a/src/process.c b/src/process.c index 5d78c295..153dc67d 100644 --- a/src/process.c +++ b/src/process.c @@ -62,26 +62,23 @@ static bool install_service(void) { return false; } - if(!strchr(program_name, '\\')) { - GetCurrentDirectory(sizeof command - 1, command + 1); - strncat(command, "\\", sizeof command - strlen(command)); - } - - strncat(command, program_name, sizeof command - strlen(command)); + HMODULE module = GetModuleHandle(NULL); + GetModuleFileName(module, command + 1, sizeof(command) - 1); + command[sizeof(command) - 1] = 0; - strncat(command, "\"", sizeof command - strlen(command)); + strncat(command, "\"", sizeof(command) - strlen(command)); for(char **argp = g_argv + 1; *argp; argp++) { char *space = strchr(*argp, ' '); - strncat(command, " ", sizeof command - strlen(command)); + strncat(command, " ", sizeof(command) - strlen(command)); if(space) - strncat(command, "\"", sizeof command - strlen(command)); + strncat(command, "\"", sizeof(command) - strlen(command)); - strncat(command, *argp, sizeof command - strlen(command)); + strncat(command, *argp, sizeof(command) - strlen(command)); if(space) - strncat(command, "\"", sizeof command - strlen(command)); + strncat(command, "\"", sizeof(command) - strlen(command)); } service = CreateService(manager, identname, identname,