Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Using the Run Commands on Parameter String with Spaces and/or Quote Marks

Keywords:  Parsing Quotes Spaces  quote marks 

Question:

How do I use the RunWait Command on a parameter string that has spaces in it? It doesn't seem to parse it correctly.

I am trying to execute an email program (Pegasus Mail v2.4 for Windows ) from its command line with various switches. This is so a user can email me automatically from within a WinBatch EXE as part of an error-handling routine.

I want the mail program to mail me with a subject line, but this must enclosed in double quotation marks on the command line after the switch -s, eg

WINPMAIL.EXE -t my_email_address -s "Subject string" 
** Can WinBatch handle this in the Run or RunWait functions ? Because otherwise it will report an error as it sees an invalid number of arguments to these commands. Can I somehow "escape" the quote marks inside the command line parameters I give to the Run or RunWait command ? **

Answer:

Just use a different kind of quote. Winbatch recogizes all three: " ` '

Just start and stop each string with the same kind. Then you can embed the others in it. You can surround the parameter string with double quotes, and change the outside quotes in the Run statement to single quotes, as in:

  name_of_user = "John Doe" 
  runwait('setup','xx yy /t:"%name_of_user%"') 
Another example:
  Run('winpmail.exe', '-t my_email_address -s "subject string"')
And another:
	run("Excel.exe", '"c:\My Documents\2 eftproc.xls"')

Article ID:   W13281
Filename:   Use Run Commands on Strings with Quotes Spaces.txt