water Posted November 26, 2010 Posted November 26, 2010 A question for the gurus on this forum Our ServiceDesk tool is going to call a compiled AutoIT script. It passes parameters in the format as PowerShell gets them (I was told). Its either -xxxx=1234or -yyyy="String value" What do you think is the best way to parse the parameter string and set the variables in AutoIt? So in my script the variable $xxxx should have the value 1234 and $yyyy should be "String value". I haven't coded anything yet but would be grateful for any idea on how to start. Thanks! My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
UEZ Posted November 26, 2010 Posted November 26, 2010 What about this method? #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Change2CUI=y #include <Array.au3> If Not $CmdLine[0] Then Exit ConsoleWrite("No parameter found!" & @CRLF) Dim $variables[1] For $i = 1 To $CmdLine[0] $val = StringRegExp( $CmdLine[$i], "-(.*)=(.*)", 3) Assign($val[0], $val[1], 2) _ArrayAdd($variables, String($val[0])) Next $variables[0] = UBound($variables) - 1 For $i = 1 To $variables[0] ConsoleWrite($variables[$i] & "=" & Eval($variables[$i]) & @CRLF) Next This is just a basic solution without checks whether the parameters are really like -XXXX=YYYY Br, 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
water Posted November 26, 2010 Author Posted November 26, 2010 Hi UEZ, vielen Dank! I had a quick test and it's working perfect. Even embedded blanks are handled correctly: C:\TEMP>test.exe -xxx="Dies ist ein Test" -yyy=123 -zzz=Normal xxx=Dies ist ein Test yyy=123 zzz=Normal Thanks a lot! My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
UEZ Posted November 26, 2010 Posted November 26, 2010 On 11/26/2010 at 11:40 AM, 'water said: Hi UEZ, vielen Dank! I had a quick test and it's working perfect. Even embedded blanks are handled correctly: C:\TEMP>test.exe -xxx="Dies ist ein Test" -yyy=123 -zzz=Normal xxx=Dies ist ein Test yyy=123 zzz=Normal Thanks a lot! Bitte sehr! Gruß, 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
water Posted November 26, 2010 Author Posted November 26, 2010 (edited) One small question: Your RegExp splits at the last "=" in the parameter. Is it possible to split at the first "="? The parameter -sOU="OU=Spezial_Policy_Stufe_0,OU=MyCompany,OU=User_Accounts,DC=microsoft,DC=com" now returns $val[0] = "sOU=OU=Spezial_Policy_Stufe_0,OU=Konzern,OU=User_Accounts,DC=company,DC" $val[1] = "com" but I need $val[0] = "sOU" $val[1] = "OU=Spezial_Policy_Stufe_0,OU=Konzern,OU=User_Accounts,DC=company,DC=com" Is this possible? Thanks in advance! Edited October 12, 2019 by water My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Tvern Posted November 26, 2010 Posted November 26, 2010 Untested, but try to replace: "-(.*)=(.*)" with "-(.*?)=(.*)"The question mark will make that group look for the smallest match, instead of the largest.
water Posted November 26, 2010 Author Posted November 26, 2010 Hi Tvern, thanks a lot for the fast reply! Your solution works fine! Have a nice weekend! My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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