# Subprocess on Windows

**URL:** <https://www.ruby-forum.com/t/subprocess-on-windows/97662>\
**Category:** Ruby\
**Created:** [January 26, 2006, 3:29pm UTC](https://www.ruby-forum.com/t/subprocess-on-windows/97662 "2006-01-26T15:29:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![interceptpoint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/58f4c7/32.png) [@interceptpoint](https://www.ruby-forum.com/u/interceptpoint)\
**Post date:** [January 26, 2006, 3:29pm UTC](https://www.ruby-forum.com/t/subprocess-on-windows/97662/1 "2006-01-26T15:29:29Z")

</div>

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. ☹

---

<div class="post-metadata">

**Author:** ![interceptpoint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/58f4c7/32.png) [@interceptpoint](https://www.ruby-forum.com/u/interceptpoint)\
**Post date:** [January 26, 2006, 4:20pm UTC](https://www.ruby-forum.com/t/subprocess-on-windows/97662/2 "2006-01-26T16:20:48Z")

</div>

Jeffrey S. 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
```

---

<div class="post-metadata">

**Author:** ![interceptpoint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/58f4c7/32.png) [@interceptpoint](https://www.ruby-forum.com/u/interceptpoint)\
**Post date:** [January 26, 2006, 5:03pm UTC](https://www.ruby-forum.com/t/subprocess-on-windows/97662/3 "2006-01-26T17:03:21Z")

</div>

Jeffrey S. 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.

---

<div class="post-metadata">

**Author:** ![interceptpoint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/58f4c7/32.png) [@interceptpoint](https://www.ruby-forum.com/u/interceptpoint)\
**Post date:** [January 26, 2006, 10:08pm UTC](https://www.ruby-forum.com/t/subprocess-on-windows/97662/4 "2006-01-26T22:08:32Z")

</div>

On 1/26/06, Jeffrey S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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}`
