Forum: Ruby system() with .msi files on WinXP

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
02bd6b98b7c04f9ae5868eda3d01fb73?d=identicon&s=25 Brad Tilley (rtilley)
on 2006-04-05 00:00
(Received via mailing list)
I have a ruby script that installs several windows applications like
this:

programs.each { |p| system(p) }

This works great with .exe installers, but if the program is a .msi
installer, nothing happens and ruby exits with 0.

With Python, os.system(installer.msi) works great. Perhaps in Ruby I
should do this differently? Any suggestions?

Thanks,
Brad
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 Joel VanderWerf (Guest)
on 2006-04-05 00:09
(Received via mailing list)
rtilley wrote:
> Thanks,
> Brad

What about

  system "start #{p}"

just a guess...
Af3f52d9cbe0a565f8b39586172fa57c?d=identicon&s=25 Miles Monroe (Guest)
on 2006-04-05 01:24
Joel VanderWerf wrote:
> rtilley wrote:
>> Thanks,
>> Brad
>
> What about
>
>   system "start #{p}"
>
> just a guess...

msiexec /? and see MSDN

Use "msiexec"

Make sure you pass the right switches for a silent install.
02bd6b98b7c04f9ae5868eda3d01fb73?d=identicon&s=25 Brad Tilley (rtilley)
on 2006-04-05 02:30
(Received via mailing list)
Miles Monroe wrote:
>>
>>just a guess...
>
>
> msiexec /? and see MSDN

I've tried that and start... still no go. Here's the code:

def install_programs(program_list)
   #program_list is a list of absolute paths.
   program_list.each do |wup|
     Dir.chdir(File.dirname(wup))
     puts Dir.getwd
     puts(File.basename(wup))
     system('msiexec -i #{File.basename(wup)}')
     end
end

system on windows is problematic! I think this is more of a windows
issue than a ruby issue as I have the same problem with python and ruby
when working with system.
Be3f276f615e29a7c605efd1d3bc3cae?d=identicon&s=25 Mike (Guest)
on 2006-04-05 02:36
(Received via mailing list)
> end
>
> system on windows is problematic! I think this is more of a
> windows issue than a ruby issue as I have the same problem
> with python and ruby when working with system.
>
Try working backwards - install the .msi manually using msiexec.exe
<switches> file.msi at the command line. Once you know it works, create
a
script that just calls system('what_worked_above').

Does that work?

Then, once you know what works with MSI, build that into the script. If
it
doesn't work with the one-line system() script, then I'm not sure what
to
suggest.

-M
02bd6b98b7c04f9ae5868eda3d01fb73?d=identicon&s=25 Brad Tilley (rtilley)
on 2006-04-05 02:54
(Received via mailing list)
Mike wrote:
>>end
> Does that work?
Sort of...

'msiexec -i installer.msi' from a cmd prompt translates to this in Ruby:

# Works in Ruby:
system('msiexec -i installer.msi')

This works fine. But string interpolation does not work, and it should,
right?

# Fails in Ruby:
system('msiexec -i #{File.basename(wup)}')
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 Joel VanderWerf (Guest)
on 2006-04-05 03:12
(Received via mailing list)
rtilley wrote:

> # Fails in Ruby:
> system('msiexec -i #{File.basename(wup)}')

Interpolation only happens in double quotes. Try:

system("msiexec -i #{File.basename(wup)}")
This topic is locked and can not be replied to.