Jump to content

How do I run AUTOIT generated executable


Recommended Posts

Hi

I generated an exe from the AutoIT and now I am trying to run it in a host which does not have AutoIT installed.

The script run fines if i run the .au3 file in the "AutoIT installed" host but if I try to run the exe that the compiler generated in other host it gives an error "Variable used is not defined (-1)"

Does anyone have any idea why this error is coming or do I need to compile it in some special manner to make it work elsewhere?

Thanks

Crescentic

Link to comment
Share on other sites

  • Developers

Its likely that this error isn't related to compiling it... but showing the script will help to determine that ......

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

The executable should work whether they have AutoIt installed or not since the executable is no longer dependent to AutoIt. I made several executables to know for sure.

But your scripts seems to have a dependent variable and if you post your code, we may be able to help you further.

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

  • Developers

I figured that out.

I was using a variable @scriptname which is not recognized by the "exe".As soon as I removed this variable the program runs fine (Since the there is no script at all now!!)

I think such a thing should be documented

Why is it the Helpfile gets the blame here ?

@ScriptName

Filename of the running script.

Which part is wrong here ?

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

Why is it the Helpfile gets the blame here ?

Which part is wrong here ?

Well if I use the variable @ScriptName and generate a exe out of that code it would never work since I am not using the Script any longer.So either the compiler should warn me that the executabe would not work because of the variable or this thing should be documented...

There was no way for me to know it right if I hadn't tried different things because run time rror just says that the variable not defined which is almost close to a complation error in the first place except that it does not point to the line number

Link to comment
Share on other sites

  • Moderators

Well if I use the variable @ScriptName and generate a exe out of that code it would never work since I am not using the Script any longer.So either the compiler should warn me that the executabe would not work because of the variable or this thing should be documented...

There was no way for me to know it right if I hadn't tried different things because run time rror just says that the variable not defined which is almost close to a complation error in the first place except that it does not point to the line number

I'm confused... @ScriptName ... Says it's definition is the script name... What should be changed and or noted for those that don't understand Script versus Executable?

@AutoItExe .... hmm ;):)

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.

Link to comment
Share on other sites

  • Developers

Well if I use the variable @ScriptName and generate a exe out of that code it would never work since I am not using the Script any longer.So either the compiler should warn me that the executabe would not work because of the variable or this thing should be documented...

There was no way for me to know it right if I hadn't tried different things because run time rror just says that the variable not defined which is almost close to a complation error in the first place except that it does not point to the line number

Still don't understand:

For example if my scriptname is TEST.au3 then this script:

MsgBox(262144,"debug",'@ScriptName:' & @ScriptName )

Will return when run as au3: @ScriptName:TEST.AU3

and compiled will show: @ScriptName:TEST.EXE

For the record: AUT2EXE does not check the validity of the script. that can be done by au3check and when you install SciTE4AutoIt3, au3check is automatically ran before aut2exe.

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

  • Moderators

Still don't understand:

For example if my scriptname is TEST.au3 then this script:

MsgBox(262144,"debug",'@ScriptName:' & @ScriptName )

Will return when run as au3: @ScriptName:TEST.AU3

and compiled will show: @ScriptName:TEST.EXE

Fore the record: AUT2EXE does not check the validity of the script. thats can be done by au3check and when you install SciTE4AutoIt3, au3check is automatically ran before aut2exe.

Even Better :) ...

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.

Link to comment
Share on other sites

I'm confused... @ScriptName ... Says it's definition is the script name... What should be changed and or noted for those that don't understand Script versus Executable?

@AutoItExe .... hmm ;):)

Dont take it the wrong way...

I like most of the features provided by AutoIT

But the error that it throws is kindda misguiding..

This error should be caught while generating the "exe" and not in the run time after the "exe" is generated

(Or there should be a list of such variables documented which would not work with the exe after it gets generated)

for example @ScriptLocation is another one.

Just a sugession for a minor improvement in the compiler.

And Yes I agree I made a mistake while using it and it should have been handled(but thats what the error reporting in the compilers are for right)

for example a good Java/C++ compiler would even warn me about a local variable which is defined but never used..

I am not asking for such radical changes but in a big script involving thousands of line such small things sometimes go unnoticed

Link to comment
Share on other sites

  • Developers

Simply put, if you compiled your script, it cease being a script, thus @ScriptName will not work. ;)

hmm, maybe put something like this in the help file as a reminder. :)

HALLLOOOOOOOO What doesn't work ??????????????????

Listen... we are open for improvements but nobody has yet told us what is wrong.

:P

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

  • Moderators

Simply put, if you compiled your script, it cease being a script, thus @ScriptName will not work. :P

hmm, maybe put something like this in the help file as a reminder. ;)

Are you sure about that?

Run this code in SciTe ... then compile it and run it: :)

Global $sVar = "am not"
If @Compiled Then $sVar = "am"
MsgBox(64, "Info", "I " & $sVar & " compiled." & @CRLF & "Here is my name: " & @ScriptName)

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.

Link to comment
Share on other sites

HALLLOOOOOOOO What doesn't work ??????????????????

Listen... we are open for improvements but nobody has yet told us what is wrong.

;)

Ok let me write the code

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_UseAnsi=y

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <LibCsv2.au3>

#cs ----------------------------------------------------------------------------

Script Function:

This script is the Basic Installation Test Script

#ce ----------------------------------------------------------------------------

;Validations and reading the data from the input csv file

If @ScriptName == 'InstallAutomation.au3' Then

$file = '..\DataFile\test.csv'

endIf

This is a Part of the code that I was trying to execute..

Initially i ran it as a script so it worked fine

But after i generated the exe to port it on another machine I forgot to remove the variable :)

Now the exe got generated fine and when I ran the executable it throws a run time error(with the usual windows run-time error window) stating that "variable used is not defined(-1) "

By looking at this error it did not remind me of what i forgot to do in my original script and then I had to go thru the entire script to find out my folly

Link to comment
Share on other sites

Are you sure about that?

Run this code in SciTe ... then compile it and run it: :)

Global $sVar = "am not"
If @Compiled Then $sVar = "am"
MsgBox(64, "Info", "I " & $sVar & " compiled." & @CRLF & "Here is my name: " & @ScriptName)
lol I was being sarcastic ;)

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

  • Developers

Ok let me write the code

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_UseAnsi=y

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <LibCsv2.au3>

#cs ----------------------------------------------------------------------------

Script Function:

This script is the Basic Installation Test Script

#ce ----------------------------------------------------------------------------

;Validations and reading the data from the input csv file

If @ScriptName == 'InstallAutomation.au3' Then

$file = '..\DataFile\test.csv'

endIf

This is a Part of the code that I was trying to execute..

Initially i ran it as a script so it worked fine

But after i generated the exe to port it on another machine I forgot to remove the variable :)

Now the exe got generated fine and when I ran the executable it throws a run time error(with the usual windows run-time error window) stating that "variable used is not defined(-1) "

By looking at this error it did not remind me of what i forgot to do in my original script and then I had to go thru the entire script to find out my folly

Ok understand this issue now... so it is not an error but a syntax issue that you were not aware of. ;)

Yes, It is the running script name which is the actual file running. so when you want to cover both options you need to change the if to e.g.:

If @ScriptName == 'InstallAutomation.au3' or If @ScriptName == 'InstallAutomation.exe" then

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

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