You are not logged in.
Pages: 1
Guys,
I have a script which needs to use the following line below, which by itself works correctly and returns the result expected:
wmic /user:.\Administrator /password:Password /NODE:PC01 /namespace:\\root\default class stdregprov call GetStringValue sSubKeyName="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI" sValueName="LastLoggedOnUser"')
but when use in a FOR LOOP such as the one below:
FOR /F "tokens=1 delims=" %y in ('wmic /user:.\Administrator /password:Password /NODE:PC01 /namespace:\\root\default class stdregprov call GetStringValue sSubKeyName="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI" sValueName="LastLoggedOnUser"') DO echo %y
It returns:
Invalid format.
Hint: <paramlist> = <param> [, <paramlist>].
Any ideas guys?
Cheers
Steve
Offline
Surround the entire command with double quotation marks and remove the internal double quotation marks since there are no spaces you have to worry about. I am not sure of the exact cause without looking into it further, but off hand it appears that when for parses the command it is separating it and causing the command not to get all the parameters at once.
for /f "delims=" %A in ('"wmic /namespace:\\root\default class stdregprov call GetStringValue sSubKeyName=SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI sValueName=LastLoggedOnUser"') do @echo %A
Offline
Pages: 1