Jump to content

Auto extracting exe file


Recommended Posts

We have a program that needs to be installed on certain computers throughout the domain and we dont want to push it out with GPO as its too big, So i though why not make a AutoIT script to use the runas function and install it.

The idea was solid and it works like a treat... I then though well why not make a self extracting exe file with winrar and get it to run the setup file when it is extracted?

sleep(5000)
If Not IsAdmin() Then
RunAs('usr', "domain", 'pass',0,@SystemDir, @SW_HIDE)
RunWait(@tempdir & "\evolve\run.bat","", @SW_HIDE)
RunWait(@tempdir & "\evolve\evolve.bat","", @SW_HIDE)
MsgBox(0,"","Evolve has been installed.")
Else
RunWait(@tempdir & "\evolve\run.bat","", @SW_HIDE)
RunWait(@tempdir & "\evolve\evolve.bat","", @SW_HIDE)
MsgBox(0,"","Evolve has been installed.")
EndIf

It appears to work fine, extracts the contacts to %temp% and launches the autoit.exe (above script) then instantly shows the msgbox..

If ii run the autoit.exe file directly from the %temp% it installs and works fine...

Any ideas on this one? or a better way for me to do this?

Az

Link to post
Share on other sites

Look up Fileinstall in the help file. You can package in lots of stuff in an AutoIt executable, including other executables.

Just yesterday, I did exactly that. I needed to run something as a user, so I ran that script directly from the parent script. I then extracted an embedded executable and ran that one as an administrator because it's function required administrative rights. Worked like a charm.

#include <ByteMe.au3>

Link to post
Share on other sites

We have a program that needs to be installed on certain computers throughout the domain and we dont want to push it out with GPO as its too big, So i though why not make a AutoIT script to use the runas function and install it.

The idea was solid and it works like a treat... I then though well why not make a self extracting exe file with winrar and get it to run the setup file when it is extracted?

sleep(5000)
If Not IsAdmin() Then
RunAs('usr', "domain", 'pass',0,@SystemDir, @SW_HIDE)
RunWait(@tempdir & "\evolve\run.bat","", @SW_HIDE)
RunWait(@tempdir & "\evolve\evolve.bat","", @SW_HIDE)
MsgBox(0,"","Evolve has been installed.")
Else
RunWait(@tempdir & "\evolve\run.bat","", @SW_HIDE)
RunWait(@tempdir & "\evolve\evolve.bat","", @SW_HIDE)
MsgBox(0,"","Evolve has been installed.")
EndIf

It appears to work fine, extracts the contacts to %temp% and launches the autoit.exe (above script) then instantly shows the msgbox..

If ii run the autoit.exe file directly from the %temp% it installs and works fine...

Any ideas on this one? or a better way for me to do this?

Az

I'm not a pro, and I am having a difficult time understanding your broken English (no disrespect intended) and the targeted problem you need help on but by what I can see, I don't know if you did this for the example only but it looks like you are trying to run the system32 directory lol.

RunAs('usr', "domain", 'pass',0,@SystemDir, @SW_HIDE)

You cannot run "system32" (You probably know that already), but make sure you're using the right "logon_flag".

I am assuming that you probably removed the program you're attempting to run and left the operating directory instead, am I right?

If so, then what exactly is your problem?

Edit: Just in case~

This function

RunAs('usr', "domain", 'pass',0,@SystemDir, @SW_HIDE)

Will have no effect on these runwait functions

RunWait(@tempdir & "\evolve\run.bat","", @SW_HIDE)
RunWait(@tempdir & "\evolve\evolve.bat","", @SW_HIDE)

So if the user is not admin, with your provided example, non of the batch files are being run with admin privileges, not sure if that is what the problem is.

Edited by THAT1ANONYMOUSEDUDE
Link to post
Share on other sites

What I am trying to do is make an .exe file that will install another program with admin rights.

I have all my files in a folder, the program installer and 2 .bat files that need to be run (one of the .bat files installs the program.)

So then I am going to package all of this up in to a SFX , This will extract all the contents to the %temp% folder on the computer and run the autoit.exe file.

I want the autoit.exe to 'runaswait' each of the .bat files to install the program.

Link to post
Share on other sites

I already told you that you do not need any other program such as WinRar. That just adds unnecessary complication.

When you compile, just have the installer in the same folder as your .au3 script. Your .au3 script should look something like this:

FileInstall("TheProgramYouWantToInstall.exe", @TempDir & "\TheProgramYouWantToInstall.exe")
RunAs("administrator", @ComputerName, "password", 1, @TempDir & "\TheProgramYouWantToInstall.exe")

The above script will pack the installer inside your AutoIt executable and extract it to the temp file. You can run cleanup afterwords with Filedelete.

Edited by sleepydvdr

#include <ByteMe.au3>

Link to post
Share on other sites

Ok i see thats a much better option and it now runs the program installer! Just need to add the silent switch which I cant seem to figure out:

; Fill in the username and password appropriate for your system.
Local $sUserName = "usr"
Local $sPassword = "pass"
Local $sDomain = "domain"
FileInstall("evolve_install.msi", @TempDir & "\evolve_install.msi")
$pid = 'Msiexec.exe /I' & @Tempdir & '\evolve_install.msi "/quiet"'
RunAs($sUserName, $sDomain, $sPassword, 0, $pid)

but all that does it bring up the msi switches, am i putting it in the correct place?

Link to post
Share on other sites

Your missing a space and some quotes in your $pid misexec.exe statement. Try this.

$pid = 'Msiexec.exe /I "' & @TempDir & '\evolve_install.msi" "/quiet"'
RunAs($sUserName, $sDomain, $sPassword, 0, $pid)

@TempDir may have some spaces, causing the problem.

Edit: Typos.

Adam

Edited by AdamUL
Link to post
Share on other sites

I still get the same issue and it showing me the msi switches.

When i started on it this morning I figured it would be nice and simple for it to run a program as an admin... how wrong I want.

I cant see why this code is not working..

; Fill in the username and password appropriate for your system.
Local $sUserName = "usr"
Local $sPassword = "pass"
Local $sDomain = "domain"
FileInstall("evolve_install.msi", @TempDir & '\evolve_install.msi")
$pid = 'Msiexec.exe /I "' & @TempDir & '\evolve_install.msi" "/quiet"'
RunAs($sUserName, $sDomain, $sPassword, 0, $pid)
MsgBox(0, "", $pid)
Link to post
Share on other sites

The Run command only starts executables. The file you are trying to run is a .msi file, not an executable. You have to launch it with shellexecute or launch it @COMSPEC, according to the help file. However, there is another way: launch it through msiexec.

Check it out:

$fileLoc = @TempDir
RunAsWait("administrator", @ComputerName, "password", 1, "msiexec /I " & '"' & $fileLoc & "\evolve_install.msi" & '"' )

#include <ByteMe.au3>

Link to post
Share on other sites

Would just like to say thanks for all the help 'Sleepydvdr' I have now managed to get it working.

final code:

; Fill in the username and password appropriate for your system.
Local $sUserName = "bob"
Local $sPassword = "Password"
Local $sDomain = @computername
$fileLoc = @tempdir
FileInstall("evolve\flash.msi", $fileLoc & '\flash.msi')
FileInstall("evolve\evolve_install.msi", $fileLoc & '\evolve_install.msi')
FileInstall("evolve\evolve.bat", $fileLoc & '\evolve.bat')
RunAsWait($sUserName, $sDomain, $sPassword, 0, "msiexec /I  " & '"' & $fileLoc & "\flash.msi" & '" /q"' &  '"ALLUSERS=2"' )
RunAsWait($sUserName, $sDomain, $sPassword, 0, "msiexec /I  " & '"' & $fileLoc & "\evolve_install.msi" & '" /q"' &  '"ALLUSERS=2"' )
RunAsWait($sUserName, $sDomain, $sPassword, 0, @ComSpec & " /c " & $fileLoc & "\evolve.bat", @SystemDir)

FileDelete($fileloc & "\flash.msi")
FileDelete($fileloc & "\evolve_install.msi")
FileDelete($fileloc & "\evolve.bat")
MsgBox(0, "", "Evolve has now been installed")

What I am going to work on now it producing some dynamic error messages and trying to make a progress bar to show the progress of the install.

az

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...