Luigi Posted October 17, 2019 Posted October 17, 2019 (edited) Greetings, I need write a command line to run an .exe with parameters, one this parameters is a password with special characters like: [ ] \ " etc. The password is write between double cotes too. When run this command line, catch error. I buid this function, sometimes run ok, others show error. Someone can any idea? Best ragards expandcollapse popup#include <Array.au3> Global $G_AIX_DEFAULT_PASSWORD = "******" Func Scape_Word_To_MSDOS($var = "") ;~ https://www.robvanderwoude.com/escapechars.php Local $aCharacters[][2] = [ _ ["%", "%%"], _ ["^", "^^"], _ ["&", "^&"], _ ["<", "^<"], _ [">", "^>"], _ ["|", "^|"], _ ["'", "^'"], _ ["`", "^`"], _ [",", "^,"], _ [";", "^;"], _ ["=", "^="], _ ["(", "^("], _ [")", "^)"], _ ["!", "^^!"], _ ["\", "\\"], _ ["[", "\["], _ ["]", "\]"], _ ['"', '\"""'], _ [".", "\."], _ ["*", "\*"], _ ["?", "\?"] _ ] Local $iSearch $var = StringSplit($var, "", $STR_NOCOUNT) Local $iSize = UBound($var, $UBOUND_ROWS) - 1 For $ii = 0 To $iSize $iSearch = _ArraySearch($aCharacters, $var[$ii]) If $iSearch >= 0 Then $var[$ii] = $aCharacters[$iSearch][1] Next Return _ArrayToString($var, "") EndFunc ;==>Scape_Word_To_MSDOS Local $password = "-Dk5iFB2UjOt[-x|""" & "" Local $password_scape = Scape_Word_To_MSDOS($password) ConsoleWrite("[" & $password & "]" & @LF) ConsoleWrite("[" & $password_scape & "]" & @LF) Edited October 17, 2019 by Luigi Visit my repository
pixelsearch Posted October 17, 2019 Posted October 17, 2019 (edited) Just now, Luigi said: The password is written between double quotes too. Hi Luigi Could the error happen when the password includes an odd number of double-quotes in it ? Another thought : Many times, within Run(), using chr(34) [which corresponds to the Ascii code of the double-quote] instead of the double-quote character itself (") makes it work in an easier way, so try to use them as much as you can within the Run command, instead of double-quotes. Those quotes & double-quotes are a real headache (especially when intermingled in a complex Run Command) Here is an example where I use them : Local $par1 = "1st par (variable)", $par2 = 2 $iPID = Run(@AutoItExe & " /AutoIt3ExecuteScript " & chr(34) & @ScriptDir & "\Run 1b.au3" & chr(34) & _ " " & chr(34) & $par1 & chr(34) & _ " " & $par2 & _ " " & "3" & _ " " & chr(34) & "4th par (string)" & chr(34)) which displays this in Run 1b.au3 : Good luck Edited October 17, 2019 by pixelsearch "I think you are searching a bug where there is no bug... don't listen to bad advice."
Luigi Posted October 17, 2019 Author Posted October 17, 2019 Thankyou @pixelsearch, I will try. I unknow about chr(34) Visit my repository
seadoggie01 Posted October 18, 2019 Posted October 18, 2019 pixelsearch's method works great. I tend to think it looks cleaner to use single quotes, but it's personal preference Local $par1 = '1st par (variable)', $par2 = 2 $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteScript "' & @ScriptDir & '\Run 1b.au3"' & _ ' "' & $par1 & '"' & _ ' ' & $par2 & _ ' ' & '3' & _ ' "4th par (string)"') All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types
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