--- spawn.cc	Thu Oct 19 13:58:16 2000
+++ spawn.cc.mine	Thu Oct 19 13:53:11 2000
@@ -352,12 +352,27 @@
   if (ac == 3 && argv[1][0] == '/' && argv[1][1] == 'c' &&
       (iscmd (argv[0], "command.com") || iscmd (argv[0], "cmd.exe")))
     {
-      one_line.add (argv[0]);
+      /* Find the full path to the executable */
+      debug_printf("looking for %s", argv[0]);
+      char sz[1024];
+      char * pch;
+      if (!SearchPath(0, argv[0], 0, sizeof(sz)/sizeof(sz[0]), sz, &pch)) {
+	debug_printf("could not find %s", argv[0]);
+	set_errno(ENOENT);
+	return -1;
+      }
+
+      debug_printf("found at %s", sz);
+
+      /* Add quotes just in case the path or filename has spaces */
+      one_line.add ("\"");
+      one_line.add (sz);
+      one_line.add ("\"");
       one_line.add (" ");
       one_line.add (argv[1]);
       one_line.add (" ");
       one_line.add (argv[2]);
-      strcpy (real_path, argv[0]);
+      strcpy (real_path, sz);
       goto skip_arg_parsing;
     }
 

