Sign in to follow this  
Followers 0
joew

How to properly execute a program from a zip file?

10 posts in this topic

Hello,

To install drivers from zip files, I came up with folowing solution:

$ziparchive = "e:\drivers\foo\bar\"

run_from_zip ("Chipset Driver Intel Ver.8.0.1.1002", "Chipset_Intel")
    WinClick ("Intel(R) Chipset Software", "Willkommen",    "[ID:1001]")
    WinClick ("Intel(R) Chipset Software", "Lizenzvertrag", "[ID:1003]")
    WinClick ("Intel(R) Chipset Software", "Readme",        "[ID:1003]")
    WinClick ("Intel(R) Chipset Software", "abgeschlossen", "[ID:1064]")
WinClose ("Chipset_Intel")

Func run_from_zip ($basename, $archdir)
        local $path  = $ziparchive & $basename
        local $title = StringLeft   ($basename, 20)
        local $zip   = ShellExecute ($path & ".zip")
        local $oldmode = AutoItSetOption ("WinTitleMatchMode", 2)
        WinWaitActive ($title)
        Send ($archdir)
        Send ("{ENTER}")

        WinWaitActive ($archdir)
        Send ("Setup.exe")
        Send ("{ENTER}")

        WinClose ($title)
        AutoItSetOption ("WinTitleMatchMode", $oldmode)
EndFunc


Func WinClick ($title, $text, $click)
        WinWaitExist ($title, $text)
        ControlClick ($title, "", $click)
EndFunc

Func WinWaitExist ($title, $text)
        while NOT WinExists ($title, $text)
                sleep (100)
        Wend
        WinActivate   ($title, $text)
        WinWaitActive ($title, $text)
EndFunc

The idea is to open the zip file in a new explorer window and then send the keystrokes to select and execute the setup.exe that is included in the zip. That worked great on my (manually configured) laptop. But it failed when I tried to reinstall the box from scratch. On the fresh install, the keystrokes were acting completely different. On the original box, typing "setup.exe" into the explorer window selected the setup.exe program and "{ENTER}" started the selected "setup.exe".

But on the freshly installed system every keystroke selects the file which begins with that letter. So (for example) "s" selects "setup.exe", the "e" select some file which starts with the letter "e" and so on. So "setup.exe" is executed only if the zip file don't contain any files which start with one of the letters "e", "t", "u", "p", "x". The rest of my autoit script fails miserably because of this.

Any ideas how to properly execute the setup program withhin an explorer window opened on a zip file?

Share this post


Link to post
Share on other sites



Might check the example forum for 7zip, there was some work done on that may help you.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Might check the example forum for 7zip, there was some work done on that may help you.

Thanks for the answer! Unfortunately, I don't get it. There are many hits, but all of them use some object stuff via Shell.Application. I don't understand this at all, but it seems to me that this is launching some external application. Do I really need this? AFACS, explorer can handle zip files out of the box. I'd rather avoid dependancy of some third-party zip-tool.

Can you please give me some more info?

Share this post


Link to post
Share on other sites

Thanks for the answer! Unfortunately, I don't get it. There are many hits, but all of them use some object stuff via Shell.Application. I don't understand this at all, but it seems to me that this is launching some external application. Do I really need this? AFACS, explorer can handle zip files out of the box. I'd rather avoid dependancy of some third-party zip-tool.

Can you please give me some more info?

No not really... I seriously have no idea what you're talking about unfortunately. I wish you well though.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

It's not creating a whole new explorer, its creating an object, to use during this process, and is not 3rd party. It is a standard function in AutoIt. I don't see what the problem is.

Share this post


Link to post
Share on other sites

Could also try the UnRar.ocx

A quick google search should find it.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

It's not creating a whole new explorer, its creating an object, to use during this process, and is not 3rd party. It is a standard function in AutoIt. I don't see what the problem is.

Ah, if it's a standard function, then it is OK. Can you please give me a pointer to some documentation or examples?

Share this post


Link to post
Share on other sites

Take a look here at the topic started by mozart90 about using the inbuilt zip object.

:)

Share this post


Link to post
Share on other sites

Take a look here at the topic started by mozart90 about using the inbuilt zip object.

Thanks for the pointer, MHz!

I can see how to create/extract zip files with this. But I'd like to execute files from the zip file without (explicitly) unpacking it. Explorer can do that when used interactively: double-klick on the zip file openes a virtual folder showing the contents of the zip file. When I double-click on one of those files, it (or the program associated with it) gets executed, without explicitly unpacking it. I understand that under the hood, explorer unpacks it. But I'd rather avoid to do this by myself.

Please check the very first message in this thread for what I'd like to do.

Share this post


Link to post
Share on other sites

Extract to temporary directory. Once you are finished running the program, delete the extracted files.

That's really the only possible way to do it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0