Re: Hiding the command window when using system() on Windows

David Mullet
Fri, 10 Nov 2006 19:40:58 -0000

Wes Gamble wrote:
> I''m making a system call in Windows to a program from within my
Rails
> app., and when it executes, a command window opens up by default for the
> duration of the program run.
>
> I''m pretty sure that there''s a way to hide this window
when I run the
> command.
>
> Does anyone know how to do this?
>
> Alternatively, I tried to set up a shortcut pointing to the executable
> that runs with the window minimized but wasn''t able to invoke it
> successfully using system(shortcut_name).
>
> Any help is appreciated.
>
> Wes

Wes-

Using the win32ole library, you could call the Run method of the
Wscript.Shell object...


require ''win32ole''
cmd = "application.exe"
windowstate = 0    # hidden
wait = 1    # wait for process to complete
WIN32OLE.new(''Wscript.Shell'').Run(cmd, windowstate , wait)


Mully