Jump to content

New to AutoIT, Compiled exe doesn't behave as expected.


Go to solution Solved by Radiance,

Recommended Posts

Hey guys, I'm new to autoit, and very happy to be here. Last night I attempted to create an automation script for malwarebytes anti-malware. The script works, but not the compiled exe. The exe crashes right after the installation of the program. If someone could point me to better debugging messages, or make some corrections to my code, that would be fantastic.

 Thank you~

#include <Date.au3>
$mbamExe = @ProgramFilesDir & "\Malwarebytes Anti-Malware\mbam.exe"
$mbamPath = @ProgramFilesDir & "\Malwarebytes Anti-Malware\"
$mbamUn = @ProgramFilesDir & "\Malwarebytes Anti-Malware\unins000.exe /verysilent /suppressmsgboxes /norestart"
$mbamScanColor = 'D98DFC'
$logName = 'mbam-' & @UserName & '-PC.txt'
Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client
Opt("PixelCoordMode", 0) ;1=absolute, 0=relative, 2=client
RunWait ("mbam-setup-2.0.4.1028.exe /silent")
Run( $mbamExe, $mbamPath)
WinWait('Malwarebytes Anti-Malware (Free) 2.0.4.1028')
WinActivate('Malwarebytes Anti-Malware (Free) 2.0.4.1028')
MouseClick('primary', 650, 500, 1, 0)
While 1
  If Hex(PixelGetColor(768, 258), 6) = $mbamScanColor Then ExitLoop
  Wend
MouseClick('primary', 768, 258, 1, 0)
WinWait('Scan Log')
WinActivate('Scan Log')
MouseClick('primary', 63, 792, 1, 0)
MouseClick('primary', 52, 817, 1, 0)
MouseClick('primary', 674, 240, 1, 0)
Send($logName)
Send("!S")
Send("!Y")
Send("!S")
Send("{ENTER}")
WinWait('Scan Log')
WinActivate('Scan Log')
WinKill('Scan Log')
WinWait('Malwarebytes Anti-Malware (Free) 2.0.4.1028')
WinActivate('Malwarebytes Anti-Malware (Free) 2.0.4.1028')
WinKill('Malwarebytes Anti-Malware (Free) 2.0.4.1028')
Run( $mbamUn )
Link to comment
Share on other sites

  • Solution

 

The exe crashes right after the installation of the program.

 

Would be interesting to see the error message.

If I had to guess, I'd say that the Run() right after your installation kills it.

Are you sure the .exe exists already and the path is correct?

When building software installer packages I had cases where the installer.exe already ended, but launched several msiexec.exe's which did the actual installation. Since installer.exe was gone the script assumed that the installation was finished.

I'd suggest you try a MsgBox(0, "", FileExists($mbamExe)) right after the installation.

This should show you if the installation is already finished or not.

Edited by Radiance
Link to comment
Share on other sites

  • Developers

Are you Running and Compiling with the same version of AutoIt3 (x86/x64) ?

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Looks great, but am not sure you answered my question. :)

Are you running & compiling with SciTE?

Is so, could you show the SciTE output pane info of both the run and compile operation so we can check what versions you use?

Also still wondering what you mean with crash: does it just end or is there any message/error?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Sorry for the Confusion, and again thank you so much guys.

To answer your questions explicitly

Yes I am using SciTE to run and compile.

When I run it using  go(f5) the script works just fine, no errors to speak of. It does the automation I want.

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\tech\Desktop\mbam.au3"    
>Exit code: 0    Time: 87.71

Compiling doesn't seem to give any notable insight.

>"C:\Program Files (x86)\AutoIt3\SciTE\..\aut2exe\aut2exe.exe" /in "C:\Users\tech\Desktop\mbam.au3"
>Exit code: 0    Time: 0.8947

As for errors or indication of failure the program just exits. No error message to speak of.

I made a few changes to the source, so I'll post my updated script here, however the problem is persisting.

$mbamTitle = "Malwarebytes Anti-Malware (Free) 2.0.4.1028"
$mbamExe = @ProgramFilesDir & "\Malwarebytes Anti-Malware\mbam.exe"
$mbamPath = @ProgramFilesDir & "\Malwarebytes Anti-Malware\"
$mbamUn = @ProgramFilesDir & "\Malwarebytes Anti-Malware\unins000.exe /verysilent /suppressmsgboxes /norestart"
$mbamScanColor = 'D9FAEC'
$logName = 'mbam-' & @UserName & '-PC.txt'
Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client
Opt("PixelCoordMode", 0) ;1=absolute, 0=relative, 2=client
RunWait ("mbam-setup-2.0.4.1028.exe /silent")
Run( $mbamExe )
WinWait($mbamTitle)
WinActivate($mbamTitle)
Sleep(200)
MouseClick('primary', 655, 493, 1, 0)
While 1
  If Hex(PixelGetColor(807, 260), 6) = $mbamScanColor Then ExitLoop
  Wend
MouseClick('primary', 807, 260, 1, 0)
WinWait('Scan Log')
WinActivate('Scan Log')
MouseClick('primary', 63, 792, 1, 0)
MouseClick('primary', 52, 817, 1, 0)
MouseClick('primary', 674, 240, 1, 0)
Send($logName)
Send("!S")
Send("!Y")
Send("!S")
Send("{ENTER}")
WinWait('Scan Log')
WinActivate('Scan Log')
WinClose('Scan Log')
WinWait($mbamTitle)
WinActivate($mbamTitle)
WinClose($mbamTitle)
Run( $mbamUn )
Edited by mcnugit
Link to comment
Share on other sites

After reinstalling Scite4autoit the output for running is as follows.

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\tech\Desktop\mbam.au3" /UserParams    
+>17:21:22 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0409)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.12.0)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\tech\Desktop\mbam.au3
+>17:21:22 AU3Check ended.rc:0
>Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\tech\Desktop\mbam.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
+>17:22:29 AutoIt3.exe ended.rc:0
+>17:22:29 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 67.42

And for compiling~

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /ShowGui /in "C:\Users\tech\Desktop\mbam.au3"
+>17:25:58 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0409)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE 
-> No changes made..
>Running AU3Check (3.3.12.0)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\tech\Desktop\mbam.au3
+>17:26:16 AU3Check ended.rc:0
>Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\aut2exe\aut2exe.exe  /in "C:\Users\tech\Desktop\mbam.au3" /out "C:\Users\Administrator\AppData\Local\AutoIt v3\Aut2exe\~AU3yukajwt.exe" /nopack /comp 2
+>17:26:17 Aut2exe.exe ended.C:\Users\Administrator\AppData\Local\AutoIt v3\Aut2exe\~AU3yukajwt.exe. rc:0
+>17:26:17 Created program:C:\Users\tech\Desktop\mbam.exe
+>17:26:18 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 20.71

Thanks JohnOne

Link to comment
Share on other sites

It's not normal to have the spaces before and after like you are using with your Run commands, inside the brackets.

Why are you doing that?

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...