- - - - - - - begin screen capture WinXP MCE 2005 SP2 - - - - - - -
c:\cmd>demo\DetectParms program.exe /a /c
slasha=yes
slashc=yes
c:\cmd>demo\DetectParms program.exe /b /c
slashb=yes
slashc=yes
c:\cmd>demo\DetectParms program.exe /c /b /a
slasha=yes
slashb=yes
slashc=yes
c:\cmd>demo\DetectParms program.exe /z
Environment variable slash not defined
c:\cmd>wyllist demo\DetectParms.cmd
==========begin file c:\CMD\DEMO\DetectParms.cmd ==========
01. @echo off
02. setlocal enabledelayedexpansion
03. for %%a in (a b c) do (
04. echo/%*|findstr /c:"/%%a">nul
05. if !errorlevel! equ 0 set slash%%a=yes
06. )
07. set slash|find "yes"
==========end file c:\CMD\DEMO\DetectParms.cmd ==========
- - - - - - - end screen capture WinXP MCE 2005 SP2 - - - - - - -
--
Phil Robyn
University of California, Berkeley
Thanks Phil. That helps a bit and gives me a couple ideas, but I probably
didn't describe the problem clearly enough. /a /b /c were meant to
represent variables passed to the program. eg /a=1234 /b=abcd /c=1a2b etc.
The program must put any combination of these variables into the appropriate
environment variable for further processing.
Thanks -Rob-
You cannot use /a=1234 /b=abcd /c=1a2b etc. unless they are each double
quoted, is that what you mean?
The equals sign is a delimiter on the command line.
@echo off & setlocal enableextensions enabledelayedexpansion
set p1=%1
set p2=%2
set p3=%3
for %%p in (p1 p2 p3) do (
if defined %%p echo !%%p!|find /i "/a">nul
if !errorlevel! EQU 0 (
set a_=!%%p!
set a_=!a_:/a=!
)
if defined %%p echo !%%p!|find /i "/b">nul
if !errorlevel! EQU 0 (
set b_=!%%p!
set b_=!b_:/b=!
)
if defined %%p echo !%%p!|find /i "/c">nul
if !errorlevel! EQU 0 (
set c_=!%%p!
set c_=!c_:/c=!
)
)
echo a_=%a_%
echo b_=%b_%
echo c_=%c_%
endlocal & goto :EOF
Output:
C:\_D\TEST>cmdfaq /babcd /c1a2b /a1234
a_=1234
b_=abcd
c_=1a2b
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip
Well, yeah, I think you haven't fully described the problem. So what are the
appropriate environment variables?
OK, the first one is an IP address, the second is a name string and the
third is a pocketsize.
Would something like this work...
my /a:pad /be:name /co:size
Timor had an interesting solution in a previous reply that I will also have
to explore.
Thanks -Rob-
"Timo Salmi" <t...@uwasa.fi> wrote in message
news:443e85ec$0$7489$9b53...@news.fv.fi...
Write SET /? and read the explanation after
Environment variable substitution has been enhanced as follows:
%PATH:str1=str2%
> Also if I omit the /b parameter as in cmdfaq /a1234 /c1a2b it
> doesn't run correctly.
Quite, it doesn't. It requires three parameters. But the task is
artificial anyway. Unnecessary complications. Usually one would
simply use straight parameters is in
%1 %2 %3
without the /b parameter complications. The only advantage is that
the parameters could be given in any order. Why make a script that
complicated?