Bat file that alters specific xml element optimization -


i have batch script updates httptransport element httpstransport specific binding name, in case: custombinarybinding. how can write in more elegant , efficient way.

bat file:

@echo off setlocal enabledelayedexpansion  set "search=httptransport" set "replace=httpstransport" set "bindingname=custombinarybinding" set intextfile=c:\users\tudor\desktop\batch\web.config set outtextfile=c:\users\tudor\desktop\batch\webtemp.config     echo start (for /f "delims=" %%i in (!intextfile!) (     set "line=%%i"     /f tokens^=1^,2^,3^ delims^=^<^"^= %%a in ("%%i") (           if "%%b" equ "binding name" if "%%c" equ "custombinarybinding" (             set "insidecorrectbinding=y"             )                                       /f "delims= " %%m in ("%%b") (             if "%%m" equ "httptransport" (                           set "oncorrectline=y"                                                                                            )         )     )     if !insidecorrectbinding! equ y if !oncorrectline! equ y (         set "line=!line:%search%=%replace%!"           set "oncorrectline="               set "insidecorrectbinding="     )                 echo(!line!                      ) )>"%outtextfile%" 

web.config:

<configuration>               <system.servicemodel>                   <bindings>                       <custombinding>                           <binding name="custombinarybinding">                             <binarymessageencoding />                             <httptransport maxreceivedmessagesize="2147483647" maxbuffersize="2147483647" />                           </binding>                       </custombinding>                   <custombinding>                           <binding name="custombinarybinding2">                             <binarymessageencoding />                             <httptransport maxreceivedmessagesize="2147483647" maxbuffersize="2147483647" />                           </binding>                       </custombinding>                         </bindings>                   <client>                     <endpoint address="../../platformadminutil.svc"                          binding="custombinding" bindingconfiguration="custombinarybinding"                          contract="platformadminutil.platformadminutil" name="custombinding_platformadminutil" />                     <endpoint address="../../entityaccess.svc"                           binding="custombinding" bindingconfiguration="custombinarybinding"                           contract="platformentityaccess.entityaccess" name="custombinding_entityaccess" />                     <endpoint address="../../entityadminaccess.svc"                           binding="custombinding" bindingconfiguration="custombinarybinding"                           contract="platformentityadminaccess.entityadminaccess" name="custombinding_entityadminaccess" />                     <endpoint address="../../logerrorservice.svc"                          binding="custombinding" bindingconfiguration="custombinarybinding"                          contract="loggerservice.logerrorservice" name="custombinding_logerrorservice" />                   </client>               </system.servicemodel>           </configuration>           

if !insidecorrectbinding! equ y if !oncorrectline! equ y ( 

should be

if defined insidecorrectbinding if  defined oncorrectline ( 

if these not set code interpreted as

if equ y if equ y ( 

which should generate error.

since these variables can set nothing or y, if defined appropriate query mechanism


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -