I am looking to implement a simple batch file that will rename the current local profile folder, backup registry keys then delete profile list SID keys. Therefore allowing the computer to create a new local profile that is not temporary.
Where %U%
is the account name
set a=wmic useraccount where name="%U%" get sid /value
and so when I execute the below(Where %a%
is the above command):
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%a% /f
it interprets it as:
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\wmic useraccount where name="%U%" get sid /value"
But I want:
"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\SID=S-1-5-21-3519583588-1143172139-1479499458-1001"
If I call %a%
, it displays
SID=S-1-5-21-3519583588-1143172139-1479499458-1001
and if I echo %a%
, it displays
wmic useraccount where name="%U%" get sid
If I just enter %a%
, it displays
SID=S-1-5-21-3519583588-1143172139-1479499458-1001
Just an explanation for why this happens would be great.