system() with .msi files on WinXP

R

rtilley

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
 
J

Joel VanderWerf

rtilley said:
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

What about

system "start #{p}"

just a guess...
 
M

Miles Monroe

Joel said:
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.
 
R

rtilley

Miles said:
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.
 
M

Mike

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.
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
 
R

rtilley

Mike said:
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?

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)}')
 
J

Joel VanderWerf

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

Interpolation only happens in double quotes. Try:

system("msiexec -i #{File.basename(wup)}")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,204
Messages
2,571,066
Members
47,672
Latest member
svaraho

Latest Threads

Top