Running this file with Ruby’s CUI interpreter hides the target file, but
running it as an rbw or with the GUI interpreter doesn’t hide the file.
I have tried IO.popen and various other methods to hide this file but so
far have drawn a blank, the Win32API and dl approaches keep giving me
invalid methods or deprecation errors. It works fine using the console
Ruby, but I’m using Tk as a GUI so I don’t want a console window to
appear. It looks like a bug, as I thought the same commands would work
with either interpreter.
Any ideas as to why this happens or how to get around it?
It works for me on Win XP. What is the return value of #system call?
Have you tried using backticks or Kernel#spawn instead?
– Matma R.
Thanks for your response.
Spawn and backticks both work with CUI but not GUI. I’ll try out another
PC and see if it’s my interpreter that’s acting up. I’ll reply with the
results.
It works for me on Win XP. What is the return value of #system call?
Have you tried using backticks or Kernel#spawn instead?
– Matma R.
Thanks for your response.
Spawn and backticks both work with CUI but not GUI. I’ll try out another
PC and see if it’s my interpreter that’s acting up. I’ll reply with the
results.
Joe
It works in Windows XP but fails on both Win7-64 machines I have acess
to. Looks like WinPE platform issue?
It works for me on Win XP. What is the return value of #system call?
Have you tried using backticks or Kernel#spawn instead?
– Matma R.
Thanks for your response.
Spawn and backticks both work with CUI but not GUI. I’ll try out another
PC and see if it’s my interpreter that’s acting up. I’ll reply with the
results.
Joe
It works in Windows XP but fails on both Win7-64 machines I have acess
to. Looks like WinPE platform issue?
I have tried the attrib command on Windows 7 independantly of Ruby and
it works from both the command console and the Run command. I can only
assume that the command isn’t being properly passed by Rubyw.exe on
post-XP Windows systems.
It works for me on Win XP. What is the return value of #system call?
Have you tried using backticks or Kernel#spawn instead?
– Matma R.
Thanks for your response.
Spawn and backticks both work with CUI but not GUI. I’ll try out another
PC and see if it’s my interpreter that’s acting up. I’ll reply with the
results.
Joe
It works in Windows XP but fails on both Win7-64 machines I have acess
to. Looks like WinPE platform issue?
I have tried the attrib command on Windows 7 independantly of Ruby and
it works from both the command console and the Run command. I can only
assume that the command isn’t being properly passed by Rubyw.exe on
post-XP Windows systems.
Based on further rb/rbw testing on Win7, it looks like GUI doesn’t allow
system commands that would normally be linked the the console, like
attrib or cmd. Notepad launches fine from both of the interpreters.
Interestingly the system command returns true even when it has no
effect.
I disabled User Account Control, and checked that the permissions are
the same for CUI and GUI, no change. It must be something in the exe
itself.
As a stopgap solution, have you tried using something like
system 'cmd /c "attrib +h aaa.txt"'
?
– Matma R.
That works with an .rb extension but not .rbw
Seems to be DOS based commands that aren’t working without a console,
and that extends to cmd itself.
Interestingly I do get a flicker of a cmd window running that with
rubyw, but it doesn’t hide the file.
It works if I use command prompt with ruby and run ‘rubyw.exe test.rbw’
from inside the command prompt window.
Am Sat, 21 Jul 2012 04:06:37 +0900
schrieb Joel P. [email protected]:
That works with an .rb extension but not .rbw
Seems to be DOS based commands that aren’t working without a console,
and that extends to cmd itself.
Interestingly I do get a flicker of a cmd window running that with
rubyw, but it doesn’t hide the file.
It works if I use command prompt with ruby and run ‘rubyw.exe
test.rbw’ from inside the command prompt window.
Joe
It’s been a while since I last did some Windows stuff, but if I
remember correctly, to run any external command you need to attach a
console window to a process. ruby.exe does this by default (resulting
in the CMD popup), and rubyw.exe doesn’t do this (causing no popup).
However, this behaviour is inherited by any child processes, so if you
want to run a command from a process not having a console window
attached, you first have to allocate one using the Win32API and then
attach it to your process. I’ve not done this, but AFAIK it’s possible
with the win32-process gem and its wrapper around the CreateProcess()
Win32API function.
Am Sat, 21 Jul 2012 04:06:37 +0900
schrieb Joel P. [email protected]:
That works with an .rb extension but not .rbw
Seems to be DOS based commands that aren’t working without a console,
and that extends to cmd itself.
Interestingly I do get a flicker of a cmd window running that with
rubyw, but it doesn’t hide the file.
It works if I use command prompt with ruby and run ‘rubyw.exe
test.rbw’ from inside the command prompt window.
Joe
It’s been a while since I last did some Windows stuff, but if I
remember correctly, to run any external command you need to attach a
console window to a process. ruby.exe does this by default (resulting
in the CMD popup), and rubyw.exe doesn’t do this (causing no popup).
However, this behaviour is inherited by any child processes, so if you
want to run a command from a process not having a console window
attached, you first have to allocate one using the Win32API and then
attach it to your process. I’ve not done this, but AFAIK it’s possible
with the win32-process gem and its wrapper around the CreateProcess()
Win32API function.
By that point I may as well be using the windows API to hide the file
directly I’m using OCRA to package this program so that may complicate matters
further.
Process.detach and Thread.new didn’t work properly from an rbw either.