First I will explain the scenario:
In a machine which has the PATH environment variable corrupted/empty (no directory specified) I need to run a Batch-Script to repair and return some settings to defaults, then obviouslly the Script needs to work in a console environment even with the PATH empty so I need to specify the absolute path for each com/exe file.
Well, understanding what I've said above, why the expression inside the FOR is not working and throws a syntax error?
For /F "tokens=*" %%# in (
'"%SystemRoot%\System32\WBEM\WMIC.exe" useraccount where name^=^'%UserName%^' Get SID ^| "%SystemRoot%\System32\FINDSTR.exe" "[0-9]-[0-9]"'
) Do (
Echo %%#
)
If I remove the absolute path of the FINDSTR
command it works again as normally.
PS: I know that one solution could be using a CSV format on the WMIC query to parse the output instead trying to redirect the output to FINDSTR, but anyways I need to find a solution about the redirection for other loops where I'm having the same problem.