Is it possible to install exe via ruby code ?

Discussion in 'Ruby' started by jazzez ravi, Jan 20, 2009.

  1. jazzez ravi

    jazzez ravi Guest

    I have a exe file in c:/test.exe

    I have a script to run the exe.

    Script :

    require 'watir'
    ie=Watir::IE.new
    ie.goto("file:///C:/putty.rar")

    But unfortunately i was not able to handle the run time windows such as
    asking
    1. window with Extract and cancel option
    2. File path asking window.

    How can i automate it? please give a idea..

    Thanks in advance.
    --
    Posted via http://www.ruby-forum.com/.
    jazzez ravi, Jan 20, 2009
    #1
    1. Advertising

  2. jazzez ravi

    jazzez ravi Guest

    Sorry for the wrong code in previous post

    working code:

    require 'watir'
    ie=Watir::IE.new
    ie.goto("file:///c:/test.exe")
    --
    Posted via http://www.ruby-forum.com/.
    jazzez ravi, Jan 20, 2009
    #2
    1. Advertising

  3. jazzez ravi wrote:
    > Sorry for the wrong code in previous post
    >
    > working code:
    >
    > require 'watir'
    > ie=Watir::IE.new
    > ie.goto("file:///c:/test.exe")


    Ill share with you one of my Top Secret scripts.
    This will boost your productivity !!!


    What you need is there ..just adapt it to your needs.


    #| Pajarito de Homero /Homer Simposon's desktop bird V 1.0 - Ruby
    implementation
    #|
    #| Ejemplos:
    #|
    #| send_key_until_is_dead("Messenger Service")
    #| send_key_until_is_dead("Atari - Olimpic Games, 100 meters","a")
    #|
    #Inspired by Homer Simposon's desktop bird
    def homers_bird(dialog_name,key="{enter}")

    require 'win32ole'
    wsh = WIN32OLE.new('WScript.Shell')

    puts "Let's remember our old Atari games..!"
    puts "We'll kill <#{dialog_name}> ...."

    while wsh.AppActivate(dialog_name)
    wsh.SendKeys("{enter}")
    sleep 0.1
    puts "Shoot !"
    end

    puts "You win !!!!"

    end
    `c:\\test.exe`
    send_key_until_is_dead("Installing")
    --
    Posted via http://www.ruby-forum.com/.
    Rodrigo Bermejo, Jan 20, 2009
    #3
  4. jazzez ravi

    jazzez ravi Guest

    Hi Rodrigo Bermejo,

    Thanks for help...

    Still i am facing some issues. Details follows..

    CODE:

    def homers_bird(dialog_name,key="{enter}")
    require 'pp'
    require 'win32ole'
    require "rubygems"
    require "win32ole_pp"

    wsh = WIN32OLE.new('WScript.Shell')

    puts wsh.AppActivate(dialog_name)

    while wsh.AppActivate(dialog_name)
    wsh.SendKeys("{enter}")
    sleep 0.1
    puts "Shoot !"
    end

    puts "You win !!!!"

    end

    `C:\\MAIN\\Work\\sw\\tvcnew.exe`
    homers_bird("Setup - Total Video Converter 3.12","{enter}")

    OUTPUT:

    It doesn't automatically enter the ENTER key. So i press in manual then
    i got output like this

    false
    You win !!!

    ISSUE:

    The code --> puts wsh.AppActivate(dialog_name) sayd "false" to me. I
    tried few other EXE files also but i am still doesn't get the output.

    Please BOOST me once again...

    Waiting for ur reply
    --
    Posted via http://www.ruby-forum.com/.
    jazzez ravi, Jan 21, 2009
    #4

  5. >
    > Waiting for ur reply


    It seems your are not getting the focus on the target window.
    <the argument to AppActivate is the title displayed on the window>


    puts wsh.AppActivate("change this string until it works")
    wsh.SendKeys("{enter}")


    -r.



    --
    Posted via http://www.ruby-forum.com/.
    Rodrigo Bermejo, Jan 21, 2009
    #5
  6. jazzez ravi

    jazzez ravi Guest

    jazzez ravi, Jan 22, 2009
    #6
  7. jazzez ravi wrote:
    > Hi Rodrigo Bermejo,
    >
    > Please see the attachment and let me know ur feedback.
    >
    > Sorry for disturbing you continuously..
    >
    > Thanks in Advance.


    This strange. Are on Windows Vista /?

    -r.
    --
    Posted via http://www.ruby-forum.com/.
    Rodrigo Bermejo, Jan 26, 2009
    #7
  8. jazzez ravi

    jazzez ravi Guest

    Hi Rodrigo Bermejo,

    OS --> Windows XP + Service pack3

    >
    > This strange. Are on Windows Vista /?
    >
    > -r.


    --
    Posted via http://www.ruby-forum.com/.
    jazzez ravi, Jan 27, 2009
    #8
  9. jazzez ravi

    David Mullet Guest

    jazzez ravi wrote:
    > Hi Rodrigo Bermejo,
    >
    > Please see the attachment and let me know ur feedback.
    >
    > Sorry for disturbing you continuously..
    >
    > Thanks in Advance.


    I believe the AppActivate method searches the text in the title bar of
    the open windows.

    Based on that, and the image you provided, I suspect that the
    AppActivate method fails on this window because the window has no title
    bar.

    David

    http://rubyonwindows.blogspot.com
    --
    Posted via http://www.ruby-forum.com/.
    David Mullet, Jan 27, 2009
    #9
  10. David Mullet wrote:
    > jazzez ravi wrote:
    >> Hi Rodrigo Bermejo,
    >>
    >> Please see the attachment and let me know ur feedback.
    >>
    >> Sorry for disturbing you continuously..
    >>
    >> Thanks in Advance.

    >
    > I believe the AppActivate method searches the text in the title bar of
    > the open windows.
    >
    > Based on that, and the image you provided, I suspect that the
    > AppActivate method fails on this window because the window has no title
    > bar.
    >
    > David
    >
    > http://rubyonwindows.blogspot.com


    There are some installers which accept command line arguments.
    Have you tried in your terminal :
    installer.exe --help or installer.exe \h

    --
    Posted via http://www.ruby-forum.com/.
    Rodrigo Bermejo, Jan 27, 2009
    #10
  11. Maybe process explorer ( from sysinternals ) can help you a bit to
    locate the process you need , and you could try to get to it based on a
    PID , or it's command line . If that doesn't work , I believe Visual
    Studio has a tool ( named spy something ) , which gives you a lot of
    information about a window .
    --
    Posted via http://www.ruby-forum.com/.
    Tsunami Script, Jan 27, 2009
    #11
  12. jazzez ravi

    jazzez ravi Guest

    Hi Rodrigo Bermej,

    Finally i got the solution via command prompt. Yes, I ran the Exe from
    command prompt and ran the script now it is working fine. I am trying to
    implement via ruby code. Thanks for your big help to freshers like me...


    Hi David Mullet & Tsunami Scrip

    Thanks for your help.

    Regards,
    P.Raveendran
    http://raveendran.wordpress.com
    --
    Posted via http://www.ruby-forum.com/.
    jazzez ravi, Jan 28, 2009
    #12
  13. Tsunami Script wrote:
    > Maybe process explorer ( from sysinternals ) can help you a bit to
    > locate the process you need , and you could try to get to it based on a
    > PID , or it's command line . If that doesn't work , I believe Visual
    > Studio has a tool ( named spy something ) , which gives you a lot of
    > information about a window .


    FWIW, the AutoIt[1] package contains a tool that which will tell you a
    tonne of information about the focussed window.

    [1]http://www.autoitscript.com/autoit3/index.shtml

    HTH

    Matt
    Matt Harrison, Jan 28, 2009
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil Tomson
    Replies:
    11
    Views:
    272
    Dick Davies
    May 8, 2004
  2. Philippe Lucas
    Replies:
    0
    Views:
    127
    Philippe Lucas
    Jun 28, 2005
  3. Géraud Contisouzas
    Replies:
    1
    Views:
    105
    Victor Grey
    Sep 13, 2006
  4. Yusuf Celik
    Replies:
    1
    Views:
    119
    Rick DeNatale
    Jul 20, 2007
  5. Sangeeta Huddar
    Replies:
    1
    Views:
    114
    Sangeeta Huddar
    Feb 27, 2009
Loading...

Share This Page