Index: scripts/run-tests.sh
===================================================================
RCS file: /cvs/drupal/drupal/scripts/run-tests.sh,v
retrieving revision 1.36
diff -u -r1.36 run-tests.sh
--- scripts/run-tests.sh	19 Sep 2009 10:38:47 -0000	1.36
+++ scripts/run-tests.sh	21 Oct 2009 03:17:38 -0000
@@ -141,7 +141,7 @@
   <test1>[,<test2>[,<test3> ...]]
 
               One or more tests to be run. By default, these are interpreted
-              as the names of test groups as shown at 
+              as the names of test groups as shown at
               ?q=admin/config/development/testing.
               These group names typically correspond to module names like "User"
               or "Profile" or "System", but there is also a group "XML-RPC".
@@ -248,12 +248,22 @@
     // '_' is an environment variable set by the shell. It contains the command that was executed.
     $php = $_ENV['_'];
   }
+  // 'SUDO_COMMAND' is an environment variable set by the sudo program.
+  // Extract only the PHP interpreter, not the rest of the command.
   elseif (!empty($_ENV['SUDO_COMMAND'])) {
-    // 'SUDO_COMMAND' is an environment variable set by the sudo program.
-    // Extract only the PHP interpreter, not the rest of the command.
     list($php, ) = explode(' ', $_ENV['SUDO_COMMAND'], 2);
   }
-  else {
+  elseif (!empty($_SERVER['SUDO_COMMAND'])) {
+    list($php, ) = explode(' ', $_SERVER['SUDO_COMMAND'], 2);
+  }
+  elseif (!empty($_SERVER['OS']) && strpos($_SERVER['OS'], 'Win') !== FALSE && !empty($_SERVER['Path']) && stripos($_SERVER['Path'], 'php') !== FALSE) {
+    // Extract the PHP interpreter from the Path server variable.
+    preg_match('@;?([^;]+php[^;]*)@i', $_SERVER['Path'], $matches);
+    if (!empty($matches[1]) && file_exists($matches[1] . '/php.exe')) {
+      $php = $matches[1] . '/php.exe';
+    }
+  }
+  if (empty($php)) {
     simpletest_script_print_error('Unable to automatically determine the path to the PHP interpreter. Please supply the --php command line argument.');
     simpletest_script_help();
     exit();
