Wilson WindowWare Tech Support

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


Command Line Parameters with Apostrophe in Parameter

Keywords:    IntControl(1006,0,0,0,0)

Question:

I'm having problems in the way arguments get parsed into "param#" when they are passed into a winbatch script.

Here is how I called it:

myprogram.exe /1stArg /2ndArgRay's 3rdArg
where the params (based on space delimiting should be):
param0 = 3
param1 = /1stArg
param2 = /2ndArgRay's
param3 = 3rdArg
However I get this:
param0 = 2
param1 = /1stArg
param2 = /2ndArgRays 3rdArg
As you can see it removes the apostrophe and concatenates the rest of the arguments together.

I know this is all because apostrophe is being treated somewhat like a "beginning quote" ... but how do I get around it? I can't scan for the apostrophe "before", because the first access I get to the commandline parameters is with "param1, param2, etc etc".

Answer:

  1. It's not a legal command line nonetheless there is a workaround.

  2. Use IntControl(1006...) to get the entire unparsed command line, sorta like:
    line=IntControl(1006,0,0,0,0)
    line=strreplace(line," "," ") 
    line=strreplace(line," "," ") 
    line=strreplace(line," "," ") 
    line=strreplace(line," "," ") 
    line=strreplace(line," "," ") 
    line=strreplace(line," "," ") 
    
    param1=ItemExtract(1,line," ")
    param2=ItemExtract(2,line," ")
    param3=ItemExtract(3,line," ")
    
    Something like that anyway. Play with it a little. Watch out for path names or filenames with spaces in them.
    Article ID:   W13902
    
    Filename:   Command Line Parameters with Apostrophe in Parameter.txt