Exemplo n.º 1
0
        public CmdExeApi start()
        {
            try
            {
                PipeName.namePipeServer(ConsoleOut);         // setup namedpipe
                saveUsersWindow();
                this.sleep(250);
                // host process
                HostProcessStarted        = true;
                HostCmdExeProcess         = Processes.startProcess("cmd.exe", "", MinimizeHostWindow);
                HostCmdExeProcess.Exited += (sender, e) => HostProcessEnded = true;
                findHostProcessHandle();
                // child process
                // the ReadTimeout can be reset on next recompile
                // see http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true for details on cmd.exe redirection
                var CreateChildProcessWithRedirection = "\"{0}\" {1} > \\\\.\\pipe\\{2} 2>&1".format(ProcessToStart, Arguments, PipeName);

                restoreUsersWindow();

                hostCmd(CreateChildProcessWithRedirection);
                //ChildProcess = Processes.startProcess(ProcessToStart,ChildProcessAgumentsWithRedirection);

                //this.sleep(1000);
            }
            catch (Exception ex)
            {
                ex.log("in CmdExeApi.start");
            }
            return(this);
        }