Jump to content

Having one script create and execute another


Recommended Posts

I recall seeing something about this before, but my search skills have been failing me lately.

From what I remember, the process was basically to write the .au3 then run the autoit.exe with that .au3 as a paramater...

This doesn't seam too difficult of a concept, but if we want this initial script to be run off of another machine (one that does not have autoit installed) then we are going to need to do what? Do a FileInstall of the Autoit.exe as well?

Or is there another solution that I don't remember?

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Help File > Using AutoIt > Command Line Parameters

AutoIt specific command Line Switches

Form1: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] file [params ...]

Execute an AutoIt3 Script File

/ErrorStdOut Allows to redirect fatal error to StdOut which can be captured by an application as Scite editor. This switch can be used with a compiled script.

To execute a standard AutoIt Script File 'myscript.au3', use the command:

'AutoIt3.exe myscript.au3'

Form2: Compiled.exe [/ErrorStdOut] [params ...]

Execute an compiled AutoIt3 Script File produced with Aut2Exe.

Form3: Compiled.exe [/ErrorStdOut] [/AutoIt3ExecuteScript file] [params ...]

Execute another script file from a compiled AutoIt3 Script File. Then you don't need to fileinstall another copy of AutoIT3.exe in your compiled file.

Form4: AutoIt3.exe [/ErrorStdOut] /AutoIt3ExecuteLine "command line"

Execute one line of code.

To execute a single line of code, use the command:

Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"')

The tray icon will not be displayed when using /AutoIt3ExecuteLine

NOTE: Correct usage of single- and double- quotation marks is important, even double single.

Link to comment
Share on other sites

I recall seeing something about this before, but my search skills have been failing me lately.

From what I remember, the process was basically to write the .au3 then run the autoit.exe with that .au3 as a paramater...

This doesn't seam too difficult of a concept, but if we want this initial script to be run off of another machine (one that does not have autoit installed) then we are going to need to do what? Do a FileInstall of the Autoit.exe as well?

Or is there another solution that I don't remember?

Why not just compile the script?

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Why not just compile the script?

I wrote a program that automatically installs software packages using a "plugin" architecture. There are about 90 software packages, any time I make a global change and need to update each au3 file I also have to compile each. Having to do this I sometimes forget to compile a plugin and experience errors. It's easier to execute the au3 directly.

Edited by weaponx
Link to comment
Share on other sites

  • Developers

I am using this UDF to create a dynamic script with SciTEConfig when tasks need #RequireAdmin level access... :D

#include<file.au3>
;
$AI_Commands = 'Msgbox(1,"test 1","test1")' & @crlf
$AI_Commands &= 'Msgbox(1,"test 2","test2")' & @crlf
_RunReqAdmin($AI_Commands,0)
;
Func _RunReqAdmin($Autoit3Commands, $prompt = 1)
    Local $temp_Script = _TempFile(@TempDir, "~", ".au3")
    Local $temp_check = _TempFile(@TempDir, "~", ".chk")
    FileWriteLine($temp_check, 'TempFile') 
    FileWriteLine($temp_Script, '#NoTrayIcon') 
    If Not IsAdmin() Then 
        FileWriteLine($temp_Script, '#RequireAdmin')
        If $prompt = 1 Then MsgBox(262144, "Need Admin mode", "Admin mode is needed for this update. Asnwer the following prompts to allow the update.")
    EndIf
    FileWriteLine($temp_Script, $Autoit3Commands)
    FileWriteLine($temp_Script, "FileDelete('" & $temp_check & "')")
    If @compiled Then
        RunWait('"' & @ScriptFullPath & '" /AutoIt3ExecuteScript "' & $temp_Script & '"')
    Else
        RunWait('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & $temp_Script & '"')
    EndIf
    While FileExists($temp_check)
        Sleep(50)
    WEnd
    FileDelete($temp_Script)
EndFunc  ;==>RunReqAdmin

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

I wrote a program that automatically installs software packages using a "plugin" architecture. There are about 90 software packages, any time I make a global change and need to update each au3 file I also have to compile each. Having to do this I sometimes forget to compile a plugin and experience errors. It's easier to execute the au3 directly.

Then Just use FileInstall(). All you need is the AutoIt3.exe file.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Then Just use FileInstall(). All you need is the AutoIt3.exe file.

FileInstall() requires that I maintain a static list of files to include. My method allows a new plugin to be added similar to BartPE and my package manager will automatically detect it, the plugin format I use is a zip file containing the program to install, an automated script to complete the install, and an ini file which contains a list of mirrors to check for newer installer files (antivirus, spyware). FileInstall() will not work here.

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