From: Alex Fenton Date: 2005-09-08T23:51:30+09:00 Subject: Re: Problem with popen on windows I too would dearly love to find a solution to this. I have seen this question batted about several times over the years, but no solution. I don't know cmd.exe is invoked, but presume it acts as the shell for system() ``() and popen(). The relevant lines in win32/win32.c in the Ruby source seem to be in CreateChild (caution: IANA C-programmer) else if ((shell = getenv("COMSPEC")) && ((redir < 0 ? has_redirection(cmd) : redir) || isInternalCmd(cmd, shell))) { char *tmp = ALLOCA_N(char, strlen(shell) + len + sizeof(" /c ")); sprintf(tmp, "%s /c %.*s", shell, len, cmd); cmd = tmp; } Looking at this code and the cmd.exe reference at www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx it seemed worth trying ENV['COMSPEC'] += ' /q' in Ruby to see if switching cmd.exe's echo off would suppress the annoying box pop-up. But having done this, any system, ``, popen call then fails with ENOENT - as if Windows can't then locate the shell executable. Using command.com works for me, but still shows a pop-up box, and I can't see any suitable options to suppress it. I'm stumped from here, but perh someone with a better knowledge of Windows process internals and/or Ruby internals can help. alex Kroeger Simon (ext) wrote: > Hmm, this has no effect on the backqoutes thingie. It has an effect on > popen but whatever I put in COMSPEC it just stops working. > > C:\WINNT\system32\cmd.exe is the standard, i tried: > > C:\WINNT\system32\command.com > C:\WINNT\system32\cmd.exe /MIN > and empty > > all have the same effect: no window poping up (fine) but no process is > executed also (not so fine) > > why is cmd.exe started anyway? > > cheers > > Simon > > > >>From: Robert Klemme [mailto:bob.news@gmx.net] >> >>Kroeger Simon (ext) wrote: >> >>>Hi all, >>> >>>i'm using ruby 1.8.2 (2004-12-25) [i386-mswin32] on win2000. >>> >>>When starting my GUI app with rubyw (because i don't like the empty >>>window) there is another window poping up whenever i call popen. (or >>>use backquotes to start another process) >>> >>>Using just ruby.exe all seems fine (except the initial nasty empty >>>window) >>> >>>Someone knows a way around? >> >>Untested: maybe you can change COMSPEC env var in your ruby script to >>point to another binary that won't open a window before >>executing the new >>process. Another option might be to add a command line param >>to COMSPEC - >>although I don't know whether that would work. >> >>Kind regards >> >> robert >> >> >> > > >