Kmurray Posted January 9, 2009 Share Posted January 9, 2009 Hello - First off, I've done a ton of searching for this and just can't seem to find a similiar example. I'm sure it will be basic for you guys, so I thank you for your patience in advance. OK, so I'm re-writing a script that installed one print driver to one that installs multiple print drivers using arrays to enumerate each one. I'm having a problem transforming $hostname = '"print123.mydomain.com"' into string & variable & string format with double quotes around the whole line. My goal is to end up with a formatted string exactly like this (quotes included) "print123.mydomain.com" where 123 is sourced from a variable. I've tried using single quotes, but the two options end up like this: $host[$i] = '"print" & $number[$i] & ".mydomain.com"' Which evaluates to: "print" & $number[$i] & ".mydomain.com" And $host[$i] = '"print"' & $number[$i] & '".mydomain.com"' Which evaluates to: "print"123".mydomain.com" Any help would be greatly appreciated! -Ken Link to comment Share on other sites More sharing options...
Developers Jos Posted January 9, 2009 Developers Share Posted January 9, 2009 $host[$i] = '"print' & $number[$i] & '.mydomain.com"' SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Kmurray Posted January 9, 2009 Author Share Posted January 9, 2009 Thank you! And I hope I put enough key words for some other blunt person to find in a search. Thanks for not making fun of me! $host[$i] = '"print' & $number[$i] & '.mydomain.com"' Link to comment Share on other sites More sharing options...
Developers Jos Posted January 9, 2009 Developers Share Posted January 9, 2009 ..Thanks for not making fun of me!why? I understands it can be confusing in the beginning and you become "blind" for the obvious... but I make no promises for the future SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
sagdude Posted April 2, 2009 Share Posted April 2, 2009 $host[$i] = '"print' & $number[$i] & '.mydomain.com"' Hi! Could somebody help me with this: I am constructing the argument String like this: CODEFor $i = 2 to $CmdLine[0] Step 1 $argumentString = $argumentString & " " & $CmdLine[$i] Next and then I do this: CODEIf FileExists($oldProgram) And $CmdLine[1] = "-cmd" Then MsgBox(0, "try", $oldProgram & " " & $CmdLine[1] & $argumentString) where CODE$oldProgram = "C:\Program Files\Some Program Name" The program expects arguments in this fashion: ProgramName.exe -cmd "argument List" (with the double quote) I am not able to make this work. Thanks, Raj Link to comment Share on other sites More sharing options...
Authenticity Posted April 2, 2009 Share Posted April 2, 2009 MsgBox(0, 'try', $oldProgram & ' -cmd "' & $argumentString & '"') If $CmdLine[1] match "-cmd" then just use "-cmd", for simplicity. Also, you can double double quotes ;]"""" just to get one double quotes into double quoted string lol or use single quote and it'll look clearer. Link to comment Share on other sites More sharing options...
sagdude Posted April 2, 2009 Share Posted April 2, 2009 MsgBox(0, 'try', $oldProgram & ' -cmd "' & $argumentString & '"') If $CmdLine[1] match "-cmd" then just use "-cmd", for simplicity. Also, you can double double quotes ;]"""" just to get one double quotes into double quoted string lol or use single quote and it'll look clearer. Hi Thanks for your reply. Could you tell me why it is not working when I run it using the Run command: CODEIf FileExists($oldProgram) And $CmdLine[1] = "-cmd" Then $commandString = '"' & $oldProgram & '"' & ' -cmd "' & $argumentString & '"' Run(@ComSpec & " /c " & $commandString, "", @SW_HIDE) I also tried it without the @ComSpec but it does not work. Thanks, Raj Link to comment Share on other sites More sharing options...
Authenticity Posted April 2, 2009 Share Posted April 2, 2009 $commandString = $oldProgram & '" -cmd "' & $argumentString & '"' Run(@ComSpec & ' /k "' & $commandString) Test this one, see what you get in the command line, the title actually. If it doesn't work then you'll need to check if -cmd thing is correct. Also, verify the condition is evaluated to true because otherwise either $oldProgram doesn't contain path to existing file or $CmdLine[1] is not equal to -cmd. Link to comment Share on other sites More sharing options...
WideBoyDixon Posted April 2, 2009 Share Posted April 2, 2009 Won't it be because the program name has a space in there? You need to put quotes around the program name in that case I think ... [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
sagdude Posted April 2, 2009 Share Posted April 2, 2009 Won't it be because the program name has a space in there? You need to put quotes around the program name in that case I think ...Thanks for your replies. That worked.Could you tell me what is the difference between the /k option and the /c option to @ComSpec.The code seems to work with the /k option but not with the /c option.Thanks,Raj Link to comment Share on other sites More sharing options...
Authenticity Posted April 2, 2009 Share Posted April 2, 2009 (edited) /c = close/k = keepEdit: I think it's not what made it to work. It's just so you see what you're sending to the command line. It could be much easier to just output ti the console using ConsoleWrite and see how it's look like. Edited April 2, 2009 by Authenticity Link to comment Share on other sites More sharing options...
sagdude Posted April 2, 2009 Share Posted April 2, 2009 /c = close/k = keepEdit: I think it's not what made it to work. It's just so you see what you're sending to the command line. It could be much easier to just output ti the console using ConsoleWrite and see how it's look like.There was a bug in my code. I had an extra lead space in the $argumentStringI fixed it.Thanks,Raj Link to comment Share on other sites More sharing options...
rajeshontheweb Posted April 2, 2009 Share Posted April 2, 2009 i am sorry but just being curious, why dont i see anyone suggesting chr(34) the simples way out i use for such a situation is " & chr(34) & "Stringtobewrappedinquoteshere" & chr(34) Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet Link to comment Share on other sites More sharing options...
GEOSoft Posted April 2, 2009 Share Posted April 2, 2009 i am sorry but just being curious, why dont i see anyone suggesting chr(34) the simples way out i use for such a situation is " & chr(34) & "Stringtobewrappedinquoteshere" & chr(34)I use it often but there are other methods that will also work George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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