How to execute .exe without terminal popped up?

I call a .exe with system like this:

system "D:/example.exe"

But it always pops up the terminal window. How can I prevent the terminal shown up?

I solved it by myself, using win32ole:

require "win32ole"
WIN32OLE.new("WScript.Shell").Run("\"#{cmd}\" \"#{arg1}\" \"#{arg2}\" \"#{arg3}\" \"#{arg4}\" \"#{arg5}\" \"#{arg6}\" \"#{arg7}\"", 0, 1)
1 Like

On Windows you might also use the API’s UI.openURL() for simple things.

# Runs the Windows Calculator applet:
UI.openURL("calc.exe")

If you give a path to a file, Windows will start the application associated with it’s filetype and pass the filepath as a parameter. Ex:

# Runs the application set to open .txt files:
UI.openURL("file:///#{ENV['USERPROFILE']}/Documents/ToDo/reminders.txt")