Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
What I want to do is change AltDefaultUserName to DefaultUserName in the output going to the DefaultUserName.reg@echo off
cls
for /f "tokens=* delims= " %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon"\ ^|find "AltDefaultUserName"') do (
echo %%a >>"C:\Documents and Settings\???????\My Documents\DefaultUserName.reg"
)exit

If you don't want to use delayed expansion this one should work after <tab>'s have been change to tabs and <space>'s have been changed to spaces. That is for default formatting, I don't know if you need it all.
@echo off
for /f "tokens=2,3" %%a in ('^(reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"\ ^|find "AltDefaultUserName"^) 2^>nul') do (
echo:<space><space><space><space>DefaultUserName<tab>%%a<tab>%%b>>"C:\Documents and Settings\???????\My Documents\DefaultUserName.reg"
)Using delayed expansion:
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "delims=" %%a in ('^(reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"\ ^|find "AltDefaultUserName"^) 2^>nul') do (
set adrq=%%a
echo !adrq:AltDefaultUserName=DefaultUserName!>>"C:\Documents and Settings\???????\My Documents\DefaultUserName.reg"
)
It's a good idea to be careful with redirection >>. If your not specifying a handle and you put a space before it eg echo text >> file you will end up with the line "text " in file. echo text>>file won't give this space. That space can sometimes be a cause of alot of trouble.I'm not using pre tags because of long lines, copy the script into a text editor with wrapping disabled to see where the line breaks are.

Thanks Judago,
I am not able to test the information just now. I will post back.
Thank you for your help

Hi Judago
I have now tested the information and with a little tweak, added 4th token
@echo off
for /f "tokens=2,3,4" %%a in ('^(reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"\ ^|find "AltDefaultUserName"^) 2^>nul') do (
echo:<space><space><space><space>DefaultUserName<tab>%%a<tab>%%b<space>%%c>>"C:\Documents and Settings\???????\My Documents\DefaultUserName.reg"
)
This works brilliantly. It was just missing off the last word of the name.
The second batch was brillo from the start.
Thanks for the explanations and the help really appreciated.

![]() |
Printing RTF in Batch use...
|
Advance Batch file help n...
|

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