Jump to content

Recommended Posts

Posted

Hi I want to run my scripts every night once per hour. All my scripts contain dynamic content (I have extended content, to change url variable, so I can use my scripts on different sites), so I don't want to compile them.

Is that possible to run a script from the command line (cmd)

Using Run Script? Or anything else

Thanks!

Posted

from the help file:

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.

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Posted

I believe a better way would be to use Windows to handle that for you. I have set up scripts to run in various parts of the day at certain times. Here is an example of the app that installs the events. Of course you need to put your scripts in the right place.

Dim $Username, $Password
$Username = "USERNAME"
$Password = "PASSWORD"
RunAsSet ( $Username, @Computername, $Password )
RunWait(@ComSpec & ' /c cscript.exe /h:cscript')
Run(@ComSpec & ' /c c:\windows\system32\schtasks /create /sc MONTHLY /MO first /D MON /st 07:00:00 /TN rights /tr c:\windows\dacl.exe /ru COMPUTERNAME\USERNAME /rp PASSWORD')

In the above example, I create a scheduled task that runs Monthly on the first Monday of the month at 7am, which runs an AutoIT app (dacl.exe) under a specific username/password. This task would then appear in the Windows Task Scheduler. The SCHTASKS program comes with Windows so you don't need to install that, it should already exist within the system32 folder. Schtasks.exe is the command line application to create Scheduled Tasks. You can get more syntax for the program by looking on Technet or open the CMD and run schtasks.exe -?. The line before (cscript) is required so that the schtasks program launches correctly.

Posted

I have compiled several scripts making the .exe and had the windows scheduler run the tasks.

I was checking to see if a certain backup drive was attached, the drive letter changes depending on which drive I'm backing up to.

;*----- Parse command line parameters -----*
If @Compiled = True Then
    $sLocalDrive = $CmdLine [1]
    if StringLen($sLocalDrive) = 1 Then
        $sLocalDrive = $sLocalDrive & ":"
        EndIf
EndIf

This part of the code checks for a command line parameter after the .exe. You should be able to read an .ini file or list to get the results you need

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