[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

system() with .msi files on WinXP

Brad Tilley

4/4/2006 9:58:00 PM

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
7 Answers

Joel VanderWerf

4/4/2006 10:07:00 PM

0

rtilley wrote:
> 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...

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407


Aaron Becker

4/4/2006 11:25:00 PM

0

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.

--
Posted via http://www.ruby-....


Brad Tilley

4/5/2006 12:28:00 AM

0

Miles Monroe wrote:
> Joel VanderWerf wrote:
>
>>rtilley wrote:
>>
>>>Thanks,
>>>Brad
>>
>>What about
>>
>> system "start #{p}"
>>
>>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.

Mike

4/5/2006 12:33:00 AM

0

> 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


Brad Tilley

4/5/2006 12:54:00 AM

0

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

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

Joel VanderWerf

4/5/2006 1:10:00 AM

0

rtilley wrote:

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

Interpolation only happens in double quotes. Try:

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

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407


Brad Tilley

4/5/2006 12:44:00 PM

0

Joel VanderWerf wrote:
> rtilley wrote:
>
>
>># Fails in Ruby:
>>system('msiexec -i #{File.basename(wup)}')
>
>
> Interpolation only happens in double quotes. Try:
>
> system("msiexec -i #{File.basename(wup)}")

Great tip! That fixed it.