Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have been reading all the posts and tips here about replacing text in files. However, neither of them works for me.
I have a regfile containg a lot of "123xyz".
I want to replace them within a BAT with new text. The new text comes as a variable %var%, but also resides in a plain textfile.The variable iteself always have the format of "HKEY_USERS\S-1-2-34-5678901234-1234567890-1234567890-1003" but from time to time with different numbers.
So far I have tried sed, change, sbs2, fart, mtr and munge. Some are close to working. Anyone have a solution?

No reason CHANGE.exe won't do it. But here's the bat.
::=========================
@echo off > newfile
setLocal EnableDelayedExpansionset /p new=<var.txt
for /f "tokens=* delims= " %%a in (somereg.txt) do (
set str=%%a
set str=!str:123xyz=%new%!
echo !str! >> newfile
)
=====================================
If at first you don't succeed, you're about average.M2

Sorry for a beginner as me, but I can't manage to get this to work. Here is what my batch looks like;
@echo off
::=====================================
::Get Unique SID string
::=====================================
setlocal
REG QUERY HKU |Findstr /R "DEFAULT S-1-5-[0-9]*-[0-9-]*$" >> out.txt
type out.txt | find /v /i "DEFAULT" >sid.txt
del /q out.txt
ECHO EXIT|%COMSPEC%/KPROMPT E100'SET VAR='$_RCX$_8$_NFILE1.BAT$_W$_Q|DEBUG>NUL
TYPE sid.txt>>FILE1.BAT
CALL FILE1.BAT
DEL FILE1.BAT
copy in.org in.reg
::=====================================
::Replace 123xyz with %var% or from sid.txt in in.reg
::=====================================regedit /s in.reg
start /w exec.exe
del in.reg
del sid.txt
endlocal
exitIt is a portable application that need some registry info at HKU before starting, therefore the regfile in.org, where the SID is changed to xyz123. The in.reg would be the file where xyz123 is changed to the SID from the actual computer.

I have no idea what's going on.
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |