Windows spawn program
-
I've been playing around with the spawn command and found some interesting things. I'm setup as a regular user on Windows 10 and using SU 2016
I can easily start an external Windows program such as cutmaster.exe using the spawn command providing it is not installed in program files
filename = File.join('c:', 'program files (x86)', 'cutmaster', 'cutmaster.exe')File.file?(filename) returns true and yes the file exists
spawn(filename) gives me the error 'No such File or Directory'If I install the program somewhere else then it spawns.
However, if I use the old DOS subst command then it will spawn just fine.subst y: 'c:\program files (x86)\cutmaster'
I've tried to run the subst command from within ruby but can't seem to do it.
cmd = 'subst'
drive = 'c:'
folder = File.join('c:', 'program files (x86)', 'cutmaster')
#{cmd} #{drive} "#{folder}"
Has anyone any success doing this sort of thing?
-
Try something like:
cmd = "\"#{filename}\"" spawn(cmd)
It needs enclosing""
, since the string contains spaces...
Wherefilename
needs to be the full path to the exe file. -
Of course !! Thanks Tig
Advertisement