J'ai besoin de get a valeur in a registry clé and store in a variable using a batch fichier.
I wrote a basic ligne de commande to exemplify my logic (using echo à la place of setting a variable):
for /f "tokens=3 delims= " %%a in ('reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "LastUsedUsername" ^|findstr /ri "REG_SZ"') do echo=%%a
I expect the username to be printed dans le écran, but it ne happen.
Je suis sure the Registry valeur "LastUsedUsername" n'est pas empty, it really has data.
Également, the delimiter is a tab, not spaces.
EDIT
If Je viens de type
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "LastUsedUsername"
... it returns:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon
LastUsedUsername REG_SZ Administrador
This code
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "LastUsedUsername" ^| findstr /ri "REG_SZ"
... returns:
LastUsedUsername REG_SZ Administrador
Ensuite, when I use the for command, Je viens de get no output from echo.