|Part of the maintenance we do at my work involves rebuilding user's profiles and in windows 7 the registry key for the old profile needs to be deleted before the new profile will work correctly.|
The problem I'm running into is that in order to get the correct key to delete I need to run a query on the user's profile ID (the ID is not part of the actual key) but when either exporting to a text file or using a FOR command only the very last part of the result is being returned.
So when I run:
reg query "HKLM\SOFTWARE\WOW6432NODE\MICROSOFT\WINDOWS NT\CURRENTVERSION\PROFILELIST" /s /f %curuser%>profilerebuild.txt
FOR /F "tokens=1,2 delims= " %%A IN (profilerebuild.txt) DO set rukey=%%A
Echo Your current registry profile path is: %rukey%
(where %curuser% is set earlier in the batch file) what I get returned as %rukey% is "End of search: 1 match(es) found." rather than the key.
The confusing part is that when I have the FOR command ending with "...DO ECHO %%A" instead of "DO SET rukey=%%A" it echo's and displays the key.
Is there something that I'm overlooking with this?