Open crazynoob04 opened 6 years ago
I solved this by myself.
First thing i required this in my script:
require 'win32ole'
Then i made a batch file, containing the command i need to be printed on a file, in this case ip config > info.txt
, and i named it run.bat.
After this, I replaced system()
with the following:
WIN32OLE.new('Shell.Application').ShellExecute('run.bat','','','open',0)
As first parameter i used the batch file i just created, and the last parameter, the 0, made the trick. It sets the new cmd windows to be hided and so it wont ever pop up again.
I tried with rubyw efdsk.rb and also to build an exe with ocra. No annoying windows popping up. This wans't an ocra issue. Sorry for posting here.
I have this script:
require 'tk'
require 'tkextlib/tile'
root = TkRoot.new()
button = Tk::Tile::TButton.new(root) {text "Hello World"}.grid
button.command {system("ipconfig > info.txt")}
Tk.mainloop()
The script runs fine and there are no errors, but when i build it with ocra, and i click the 'Hello World' button from the exe file, the cmd will appear for less then a second, and this, everytime i press the button.
I also tried
Open3.popen3(cmd)
, but still the same issue as withsystem()
.If i remove or comment this line:
button.command {system("ipconfig > info.txt")}
Then the issue will disappear, so i think the problem is related to
system()
.I tried to rename my ruby file from .rb to .rbw too, and also to add
--windows [path\to\tk] --add-all-core
, still nothing.This is my ruby version:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]
This issue will appear on the following ruby versions too:
ruby 2.1.5p273 (2014-11-13 revision 48405) [x64-mingw32]
ruby 2.0.0p648 (2015-12-16) [x64-mingw32]
ruby 1.9.3p551 (2014-11-13) [i386-mingw32]