|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Batch script reading registry
Hi,
I'm using this script in GPO on Windows XP machine's. I want to read a registry value to know the last user logon in a machine but the value of AltDefaultUserName isn't stored in the var. START /W REGEDIT /E c:\test.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" FOR /F "tokens=1* delims==" %%A IN ('TYPE c:\test.reg ^¦ FIND "AltDefaultUserName"') DO SET uName=%%B SET uName=%uName:"=% echo uName Thanks. Try this:
<batch> @echo off FOR /F "tokens=3" %%A IN ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AltDefaultUserName') DO SET UID=%%A echo %UID% :end </batch>Show quote "Xavi RodrÃguez" wrote: > Hi, > > I'm using this script in GPO on Windows XP machine's. I want to read a > registry value to know the last user logon in a machine but the value of > AltDefaultUserName isn't stored in the var. > > START /W REGEDIT /E c:\test.reg > "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" > FOR /F "tokens=1* delims==" %%A IN ('TYPE c:\test.reg ^¦ FIND > "AltDefaultUserName"') DO SET uName=%%B > SET uName=%uName:"=% > echo uName > > Thanks. > > > |
|||||||||||||||||||||||