Search code examples
autoit

"Statement cannot be just an expression." -error using $CmdLine


$CmdLine[0]
$CmdLine[1]

If Not FileExists($CmdLine[1]) Then
    DirCreate($CmdLine[1])
EndIf

With this line from the command prompt it works just fine:

"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" folder-test1.au3 "C:\SomeFolder"

When I compile it into an EXE it gives me an error on each of the $CmdLine lines:

error: Statement cannot be just an expression.

Why?


Solution

  • You have to use following script (remove first 2 lines from your script):

    if not FileExists($CmdLine[1]) Then
        DirCreate($CmdLine[1])
    EndIf
    

    Then you should compile it to .exe and run. (If you are edit you script with SciTe editor, then you can compile in Tools-Compile menu)