Hi again,
I'm trying to export a registry key and then trying to get the data in a for loop with a .cmd file. But for some reason it is not looping through. Is there data in the reg file that prevents loop processing?
My final goal is to export the
hklm\software\microsoft\windows\currentversion\run
key, modify it and then import it back in. But for some reason the for loop is not even processing the tokens. Very strange.
This is just the test loop so I can echo the contents:
for /f "tokens=1,2" %%i in (temp.txt) do echo %%i %%j %%k (works)
for /f "tokens=1,2" %%i in (reg.txt) do echo %%i %%j %%k (doesn't work)
And the first line works being that I created the file.
The second line does not work (the text file was exported from reg with the .txt)
Any clues? Is this by design since it is a reg file? or should I saw "was" from the reg.exe command?
Chonn
-rock on
cmd and reg
Moderator: DosItHelp
If you export a registry key, the file is encoded in Unicode. But the for loop can't read this kind file. You need the type command.
Code: Select all
for /f "tokens=1,2" %%i in ('type reg.txt') do echo %%i %%j %%k