diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index be51dc6..63a84b0 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -1247,7 +1247,8 @@ pgwin32_CommandLine(bool registration)
 
 	if (registration)
 	{
-		ret = find_my_exec(argv0, cmdLine);
+		cmdLine[0] = '"';
+		ret = find_my_exec(argv0, cmdLine+1);
 		if (ret != 0)
 		{
 			write_stderr(_("%s: could not find own program executable\n"), progname);
@@ -1282,7 +1283,7 @@ pgwin32_CommandLine(bool registration)
 			/* If commandline does not end in .exe, append it */
 			strcat(cmdLine, ".exe");
 		}
-		strcat(cmdLine, " runservice -N \"");
+		strcat(cmdLine, "\" runservice -N \"");
 		strcat(cmdLine, register_servicename);
 		strcat(cmdLine, "\"");
 	}
