Jump to content
Sign in to follow this  
kudrow

run script with switches?

Recommended Posts

kudrow

Is there a way to run a script but pass dynamic variables to it? Maybe with switches? I want to use php to execute a script but send variables to it from the php side.

Thanks!

Share this post


Link to post
Share on other sites
JLogan3o13

Hi, kudrow, welcome to the forum. Do a search for $CmdLine and $CmdLineRaw in the help file. It helps you pass parameters to your compiled script.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
kudrow

Thats it! Thank you!

Share this post


Link to post
Share on other sites
kudrow

Well, I tried passing more than 1 parameter but only the first paramater is displayed.

My example is

run C:testtest.au3 param1 param2

The code in test.au3 is:

$t1=$CmdLine[1]

$t2=$CmdLine[2]

MsgBox (1, "test", $t2)

I am trying to get $t2 to display but no matter what I do $t1 is what is passed.

Thanks.

Share this post


Link to post
Share on other sites
UEZ

How do you run: run C:testtest.au3 param1 param2?

Compile your script and run it e.g. from cmd directly: test.exe param1 param2

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
water

Try

MsgBox (1, "test", $CmdLine[0])
to see how many parameters get passed.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
guinness

Or run it from SciTE

View > Parameters

I prefer that method too OR even Shift + F8 if I have my hands on the keyboard.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
kylomas

kudrow,

Another way to pass parms from a source script (executed from either scite or double clicking on the .au3 file)

;
; driving script
;
shellexecute('k:autoitsourceparmtest.au3','parm1 parm2 parm3=what parm4')

;
; driven script
;
#include <array.au3>
_arraydisplay($cmdline,'My command line parms')

edit: autoit has to be installed on the machine doing the shellexecute, otherwise go with the compiled option as suggested earlier.

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
kudrow

How do you run: run C:testtest.au3 param1 param2?

Compile your script and run it e.g. from cmd directly: test.exe param1 param2

Br,

UEZ

They way I was running it was (win7) start>search for run> windows run>C:testtest.au3 param1 param2. This did not work. It only returned the first parameter.

This worked. I also used the suggested

MsgBox (1, "test", $CmdLine[0]) to see how many parameters are being passed and it worked like a charm. Thank you for the awesome help everyone.

Share this post


Link to post
Share on other sites
kudrow

OK, it has been a long time since I have had a chance to play with AutoIT and I appear to be over thinking my situation. It has to be something simple.

I have a text file that is holding the contents of a $CmdLineRaw result sent from a third party application. I want to resend this same results to another application.

I am reading the text file and then trying to use RUN ("Direct Path To EXE" & $Textfromfile) It does not work. I am not sure how to do what I am trying to do.

Any Ideas?

Share this post


Link to post
Share on other sites
water

Can you please post the complete Run statement? Maybe you are just missing a space.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
kudrow

$text = FileReadLine ( $file, 1 )
MsgBox (1, "Hand Off 2 Complete", "yeah")

$command = "C:\Program Files\Optos\Optomap Applications\Capture2.exe"
Run ($command & $text)
FileClose ($file)

Share this post


Link to post
Share on other sites
water

Try:

$text = FileReadLine ( $file, 1 )
MsgBox (1, "Hand Off 2 Complete", "yeah")

$command = '"C:\Program Files\Optos\Optomap Applications\Capture2.exe"'
Run ($command & " " & $text)
FileClose ($file)
  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
kudrow

Try:

$text = FileReadLine ( $file, 1 )
MsgBox (1, "Hand Off 2 Complete", "yeah")

$command = '"C:\Program Files\Optos\Optomap Applications\Capture2.exe"'
Run ($command & " " & $text)
FileClose ($file)

Thats it!!!!! I knew it was something simple. THANK YOU!
  • Like 1

Share this post


Link to post
Share on other sites
water
:D
  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×