Forum: Ruby subprocess on Windows

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
149379873fe2cb70e550c6bff8fedd0c?d=identicon&s=25 Jeffrey Schwab (Guest)
on 2006-01-26 15:29
(Received via mailing list)
Whenever my Windows rubyw script launches a subprocess, a command window
pops up and immediately disappears.  How can I keep this from happening?

Details:

I keep a daily log of what I do at work.  At the command line, I type
"log" to edit the current day's log file.  A Ruby script generates an
appropriate name for the file automatically, then launches vim.

Now I'm trying to use the Windows GUI, and I want to have an icon I can
click to launch gvim.  Here's the code:

   # log.rbw
   # Launch gvim on today's logfile, e.g. on
   # C:\Logs\2006\2006.01\2006.01.26.txt

   logfile = Time.now.strftime('C:\Logs\%Y\%Y.%m\%Y.%m.%d.txt')
   system("gvim", logfile)

When I click the icon, I get the expected behavior, except that a
Windows cmd.exe window flashes on the screen first.  :(
5befe95e6648daec3dd5728cd36602d0?d=identicon&s=25 Robert Klemme (Guest)
on 2006-01-26 16:20
(Received via mailing list)
Jeffrey Schwab wrote:
> Now I'm trying to use the Windows GUI, and I want to have an icon I
> Windows cmd.exe window flashes on the screen first.  :(
One thing is you can change the linke to open the window minimized.  And
I
think I remember seeing a rubyw or such in the windows distribution that
does not open a cmd shell.  HTH

    robert
0817571d150afead454f4220007042fe?d=identicon&s=25 Matthew Desmarais (Guest)
on 2006-01-26 17:03
(Received via mailing list)
Jeffrey Schwab wrote:
> Now I'm trying to use the Windows GUI, and I want to have an icon I
> Windows cmd.exe window flashes on the screen first.  :(
>
>
You may want Kernel.exec instead of Kernel.system.  See ri Kernel.exec
and ri Kernel.system for more info.
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-01-26 22:08
(Received via mailing list)
On 1/26/06, Jeffrey Schwab <jeff@schwabcenter.com> wrote:
> click to launch gvim.  Here's the code:
>
>    # log.rbw
>    # Launch gvim on today's logfile, e.g. on
>    # C:\Logs\2006\2006.01\2006.01.26.txt
>
>    logfile = Time.now.strftime('C:\Logs\%Y\%Y.%m\%Y.%m.%d.txt')
>    system("gvim", logfile)
>
> When I click the icon, I get the expected behavior, except that a
> Windows cmd.exe window flashes on the screen first.  :(

Try:
`start /B gvim #{logfile}`
This topic is locked and can not be replied to.