=== modified file 'twisted/internet/_dumbwin32proc.py'
--- twisted/internet/_dumbwin32proc.py	2011-10-02 01:01:47 +0000
+++ twisted/internet/_dumbwin32proc.py	2012-07-16 21:39:49 +0000
@@ -172,8 +172,9 @@
         cmdline = quoteArguments(args)
         # TODO: error detection here.  See #2787 and #4184.
         def doCreate():
+            flags = win32con.CREATE_NO_WINDOW
             self.hProcess, self.hThread, self.pid, dwTid = win32process.CreateProcess(
-                command, cmdline, None, None, 1, 0, env, path, StartupInfo)
+                command, cmdline, None, None, 1, flags, env, path, StartupInfo)
         try:
             try:
                 doCreate()

=== modified file 'twisted/test/test_process.py'
--- twisted/test/test_process.py	2012-07-08 18:39:59 +0000
+++ twisted/test/test_process.py	2012-07-19 05:27:43 +0000
@@ -27,7 +27,7 @@
 from twisted.python.log import msg
 from twisted.internet import reactor, protocol, error, interfaces, defer
 from twisted.trial import unittest
-from twisted.python import util, runtime, procutils
+from twisted.python import filepath, util, runtime, procutils
 from twisted.python.compat import set
 
 
@@ -2350,6 +2350,48 @@
 
 
 
+class Win32CreateProcessFlagsTest(unittest.TestCase):
+    """
+    Check the flags passed to CreateProcess.
+    """
+
+    @defer.inlineCallbacks
+    def test_flags(self):
+        """
+        Verify that the flags passed to win32process.CreateProcess() prevent a
+        new console window from being created. See bug #5726 for a script to
+        test this interactively.
+        """
+        from twisted.internet import _dumbwin32proc
+        flags = []
+        real_CreateProcess = _dumbwin32proc.win32process.CreateProcess
+
+        def fake_createprocess(_appName, _commandLine, _processAttributes,
+                            _threadAttributes, _bInheritHandles, creationFlags,
+                            _newEnvironment, _currentDirectory, startupinfo):
+            """Store the creationFlags for later comparing."""
+            flags.append(creationFlags)
+            return real_CreateProcess(_appName, _commandLine,
+                            _processAttributes, _threadAttributes,
+                            _bInheritHandles, creationFlags, _newEnvironment,
+                            _currentDirectory, startupinfo)
+
+        self.patch(_dumbwin32proc.win32process, "CreateProcess",
+                   fake_createprocess)
+        exe = sys.executable
+        scriptPath = filepath.FilePath(__file__).sibling("process_cmdline.py")
+
+        d = defer.Deferred()
+        processProto = TrivialProcessProtocol(d)
+        comspec = str(os.environ["COMSPEC"])
+        cmd = [comspec, "/c", exe, scriptPath.path]
+        _dumbwin32proc.Process(reactor, processProto, None, cmd, {}, None)
+        yield d
+        self.assertEqual(flags,
+                         [_dumbwin32proc.win32process.CREATE_NO_WINDOW])
+
+
+
 class UtilTestCase(unittest.TestCase):
     """
     Tests for process-related helper functions (currently only
@@ -2553,6 +2595,7 @@
     Win32ProcessTestCase.skip = skipMessage
     TestTwoProcessesNonPosix.skip = skipMessage
     Dumbwin32procPidTest.skip = skipMessage
+    Win32CreateProcessFlagsTest.skip = skipMessage
     Win32UnicodeEnvironmentTest.skip = skipMessage
 
 if not interfaces.IReactorProcess(reactor, None):

=== added file 'twisted/topfiles/5726.bugfix'
--- twisted/topfiles/5726.bugfix	1970-01-01 00:00:00 +0000
+++ twisted/topfiles/5726.bugfix	2012-07-16 22:43:20 +0000
@@ -0,0 +1,1 @@
+spawnProcess no longer opens an unwanted console on Windows

