I am trying to test LDAP entry and passwords.
The password may contain the quote character.
I am trying to call my .bat file by:
d:\misc>Mytest.bat "Test Person" <password>
My script expects two arguments.. Name and Password.
Let's say that Test Person has the password ABV9"cc1
What must I do to get the DOS command parser to pass ABV9"cc1 as a string argument so that the script can use it????????????????????
I have tried 'ABV9"cc1' and ABV9\"cc1 but always get invalid command syntax.
Passing argument to DOS script containing a quote
Moderator: DosItHelp
Hi Harlod,
simple if you use only one argument like the password.
Then you can use %* for all the input.
But if you use two arguments, like user and pwd, then it becomes complicated.
The first argument is obviously %1, but the SHIFT command fail for %*.
%* reflects always all arguments, not modified by shift.
I suppose the only way is to remove the first argument from the %* by counting the length of %1.
Something like
only a thought
jeb
simple if you use only one argument like the password.
Then you can use %* for all the input.
But if you use two arguments, like user and pwd, then it becomes complicated.
The first argument is obviously %1, but the SHIFT command fail for %*.
%* reflects always all arguments, not modified by shift.
I suppose the only way is to remove the first argument from the %* by counting the length of %1.
Something like
Code: Select all
@echo off
setlocal
set user=%1
set "allArgs=%*"
call :stringLen %usr% usrLen
call set pwd=%%allArgs:~%usrLen%%%
echo %pwd%
only a thought
jeb