sanfrancrisko Posted May 24, 2011 Share Posted May 24, 2011 Hi, 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! expandcollapse popup#Include <Array.au3> $Switch_count = $CmdLine[0] Local $Switch[6] for $i =0 to $Switch_count Step +1 $Switch[$i] = $CmdLine[$i] Next 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") Send("!n") Send($Switch[1]) Send("!u") Send($Switch[2]) Send("!p") Send($Switch[3]) Send("!l") WinWaitActive($Switch[1]&" - vSphere Client") Do Send("{RIGHT}") SLeep(1000) Send("{DOWN}") Sleep(1000) Until WinActive($Switch[1]&" - vSphere Client", $Switch[4]) if $switch[5] = "start" Then Send("{CTRLDOWN}") Send("b") Send("{CTRLUP}") elseif $switch[5] = "stop" Then Send("{CTRLDOWN}") Send("e") Send("{CTRLUP}") Sleep(2000) Send("y") elseif $switch[5] = "shutdown" Then Send("{CTRLDOWN}") Send("d") Send("{CTRLUP}") EndIf Sleep(5000) Send("!f") Send("x") Link to comment Share on other sites More sharing options...
sleepydvdr Posted May 24, 2011 Share Posted May 24, 2011 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: !ncommand!ucommand!pcommand!l 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> Link to comment Share on other sites More sharing options...
sanfrancrisko Posted May 25, 2011 Author Share Posted May 25, 2011 Thanks for replying sleepyThe 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! 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 192.168.1.100 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] Next!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 192.168.1.100 sanfrancrisko password123 image-to-start start...but won't work when I compile the script and try to run as an .exeMy 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! Link to comment Share on other sites More sharing options...
AndrewClim Posted November 7, 2014 Share Posted November 7, 2014 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 coffeeturtle 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 7, 2014 Moderators Share Posted November 7, 2014 AndrewClim,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? Please check the dates on threads and do not necro-post like this again. M23 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: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now