|
Answer» Okay so my goal is to edit two particular lines in an INI file. The cmd file will be ran on xp clients. The line in QUESTION will be replaced w/ the %userprofile% var. Just doing some searching on google I've found a way to replace one line successfully, but I'm stuck on replacing two. Here is the code I'm using for just the one line:
for /f "delims=" %%a in (%temp%\appsrv.ini) do ( call :PROCESS "%%a" )
goto :EOF :PROCESS set LINE=%~1 if /i "%LINE%"=="LogFileWin32=c:\documents and settings\\Application Data\ICAClient\wfcwin32.log" set LINE=LogFileWin32=%userprofile%\Application Data\ICAClient\wfcwin32.log echo %LINE%>>"%userprofile%\application data\ICAClient\APPSRV.INI" :EOf
This works perfectly, but for the life of me I cannot figure out how to make it replace a second line within the same ini file. Any help you fine people could offer would be appricated. If it would be easier simply mathing a string (eg "c:\docs & settings\user") to replace rather than the exact line of text (as it is now) is fine by me tooConsidering that any given line can either meet one condition or another condition or neither, can you not simply add another if condition:
Code: [Select]for /f "delims=" %%a in (%temp%\appsrv.ini) do ( call :PROCESS "%%a" )
goto :EOF :PROCESS set LINE=%~1 if /i "%LINE%"=="LogFileWin32=%userprofile%\Application Data\ICAClient\wfcwin32.log" ( set LINE=LogFileWin32=%userprofile%\Application Data\ICAClient\wfcwin32.log echo %LINE%>>"%userprofile%\application data\ICAClient\APPSRV.INI" ) if specifications for second condition (
)
Hope this HELPS 8-)Your code didn't quite work as expected (maybe I just used it WRONG, I'm not the greatest at this SORT of thing) but it did give me enough ideas to go on. Here's what I ended up using, in my testing it seems to work perfectly. Thanks for all your help!
Code: [Select]for /f "delims=" %%a in (%temp%\appsrv.ini) do ( call :PROCESS "%%a" ) goto :EOF :PROCESS set LINE=%~1 if /i "%LINE%"=="LogFileWin32=C:\Documents and Settings\<edit>\Application Data\ICAClient\wfcwin32.log" set LINE=LogFileWin32=%userprofile%\Application Data\ICAClient\wfcwin32.log if /i "%LINE%"=="PersistentCachePath=C:\Documents and Settings\<edit>\Application Data\ICAClient\Cache" set LINE=PersistentCachePath=%userprofile%\Application Data\ICAClient\Cache echo %LINE%>>"%userprofile%\application data\ICAClient\APPSRV.INI" :EOF
|