cmd and reg

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Chonn
Posts: 9
Joined: 17 Mar 2009 13:12

cmd and reg

#1 Post by Chonn » 11 May 2009 19:20

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

Batcher
Posts: 74
Joined: 16 Apr 2009 10:36

#2 Post by Batcher » 12 May 2009 00:00

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

Chonn
Posts: 9
Joined: 17 Mar 2009 13:12

#3 Post by Chonn » 12 May 2009 12:18

that works! SWEET!

Thank you very much!

Chonn
-rock on

Post Reply