validation - How to pass paramaters like unix into windows batch file -


i need pass various parameters .cmd file unix format

file.cmd -configuration=value -source=value -flag

but, try this:

startlocal  @echo off cls  setlocal set cmdline=%* set configuration= set source= set badargs= set validation= goto main  :splitargs   echo splitargs(%*)   if "%*" neq "" (     /f "tokens=1,2,* delims== " %%i in ("%*") call :assignkeyvalue %%i %%j & call :splitargs %%k   )   goto :eof  :assignkeyvalue   echo   assignkeyvalue(%1, %2)   if /i %1==-configuration (     set configuration=%2   ) else if /i %1==-source (     set source=%2   ) else (     rem append unrecognised [key,value] badargs     echo unknown key %1     set badargs=%badargs%[%1, %2]   )   goto :eof  :validate  echo validating  set validation=fail  if defined configuration (    echo   -configuration ok    if defined source (      echo   -source ok        if not defined badargs (          set validation=success        )    )  )  goto :eof  :main   cls   call :splitargs %cmdline%   call :validate   if "%validation%" equ "success" (     echo -configuration = %configuration%     echo -source = %source%   )  

but have problems, because when write parameter in mode

file.cmd source=value

always take value,i need validate this, idea... thank you

try this:

file.cmd "source=value"  

Comments

Popular posts from this blog

ruby on rails - Is it the correct way to implement belongs_to relation with factory girl? -

geolocation - Windows Phone 8 - Keeping background location tracking active beyond four hours -

Uncaught TypeError: Cannot read property 'parentNode' of null javascript -