"Statement cannot be just an expression." - 使用 $Command Line 时出错

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

$CmdLine[0]
$CmdLine[1]

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

使用命令提示符中的这一行它工作得很好:

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

当我将它编译成 EXE 时,它在每个 $CmdLine 行:

error: Statement cannot be just an expression.

为什么?

您必须使用以下脚本(从脚本中删除前两行):

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

然后你应该把它编译成.exe 和运行。 (如果你是用SciTe编辑器编辑脚本,那么你可以在工具-编译菜单中编译)