Jump to content
Sign in to follow this  

Running compiled script with command line options

Recommended Posts


I'm having a bit of difficulty understanding how Command Line Parameters work. Usually the help file is excellent but "Command Line Parameters" is a bit ambiguous and hard to understand. Probably just me though...

The bit I'm having difficulty with is passing command line switches whenever the script is compiled. I can run the script with the appropriate commands whenever it is executed as an .au3 file but when it's compiled I receive the message, "Expected a "=" operator in assignment statement" ... as though the commands are not being passed to the .exe

When I run the program it's from the Windows "Run" prompt: myscript.exe param1 param2...etc...param5

I've tried putting the parameters in double quotes too but the same message appears. The script is below - if anyone could offer any advice, thanks in advance! :huh2:

#Include <Array.au3>

$Switch_count = $CmdLine[0]

Local $Switch[6]

for $i =0 to $Switch_count Step +1
    $Switch[$i] = $CmdLine[$i]

Run("C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe", "C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\")
WinWaitActive("VMware vSphere Client")
WinActivate("VMware vSphere Client")
WinWaitActive($Switch[1]&" - vSphere Client")
Until WinActive($Switch[1]&" - vSphere Client", $Switch[4])

if $switch[5] = "start" Then
elseif $switch[5] = "stop" Then
elseif $switch[5] = "shutdown" Then


Share this post

Link to post
Share on other sites

What does sending !n, !u, !p, !l do? What are the commands for $Switch[1], [2] & [3]?

Also, you may need to put a space between statements and switches. It looks like to me you will send something like:


The code may need to something like:

Send("!n ")  ;<-- note the space after the n
Send($Switch[1] & " ")  ;<-- added a space after the switch
Send("!u ")
Send($Switch[2] & " ")
Send("!p ")
Send($Switch[3] & " ")
Send("!l ")

That would produce this:

!n command !u command !p command !l

#include <ByteMe.au3>

Share this post

Link to post
Share on other sites

Thanks for replying sleepy

The script automates logging in to VMWare vSphere Client because to enable the CLI on VMWare server would cost an additional $1000 per year, so I thought, for all I need CLI for, why not put together an AutoIT script first before spending that! :huh2:

When vSphere is initially run, a dialog box appears with "Server Name", "User Name" and "Password" to enter. So the commands !n, !u, and !p, tab to those fields. The $Switch[1], [2] & [3] array entries contain the server name/IP address, username and password. This is passed to the compiled script by putting command line parameters after the script name:

vpshere_login.exe sanfrancrisko password123 etc...

The $Switch[x] array is populated with the command line parameters using the for loop at the start of the script:

for $i =0 to $Switch_count Step +1
    $Switch[$i] = $CmdLine[$i]

!l then tabs to the "Login" button.

All that works no problem when running the script as an .au3 - i.e.:

C:\Program Files\AutoIt3\AutoIT3.exe C:\Documents and Settings\vpshere_login.exe sanfrancrisko password123 image-to-start start

...but won't work when I compile the script and try to run as an .exe

My question is - is there a difference in passing parameters to a script between .au3 and compiled .exe that I'm not picking up on in the help file?

Thanks! ;)

Share this post

Link to post
Share on other sites

hello .. you could try adding this line to your script:   #pragma compile(AutoItExecuteAllowed,true )

and check your program not having a line like :        #NoAutiotExecute         forgotten ..from here doesn't look like you have this kind of line ,but this should work ;) 

Share this post

Link to post
Share on other sites


Welcome to the AutoIt forums. :)

However, did you notice that the first post in this thread dates from over 3 years ago and that the OP has not been online for over 2 years? :huh:

Please check the dates on threads and do not necro-post like this again. ;)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...