My FOR-loops recently created some annoying error messages on both my Windows 10 and 11 computers. I could sware they worked before.
The following three command lines work fine and create the expected results:
powershell.exe -Command Get-ItemPropertyValue -Path 'HKCU:Control Panel\International\' -Name 'LocaleName'
pwsh.exe -Command Get-ItemPropertyValue -Path 'HKCU:Control Panel\International\' -Name 'LocaleName'
reg query "HKCU\Control Panel\International" /v "LocaleName"
But if I enclose them into for-loops for a SetVar-like command as follows, all three create the error message, "the entered line is too long". This happens both with cmd.exe and wt.exe, and both in direct mode and in batch mode (with %%v
). Do you have an idea what I am doing wrong here?
for /f "usebackq tokens=* delims=" %v in (`powershell.exe -NoProfile -ExecutionPolicy Bypass -Command Get-ItemPropertyValue -Path 'HKCU:Control Panel\International\' -Name 'LocaleName'`) do set "LOCALE=%v"
for /f "usebackq tokens=* delims=" %v in (`pwsh.exe -NoProfile -ExecutionPolicy Bypass -Command Get-ItemPropertyValue -Path 'HKCU:Control Panel\International\' -Name 'LocaleName'`) do set "LOCALE=%v"
for /f "tokens=3 delims= " %v in ('REG QUERY "HKCU\Control Panel\International" /v "LocaleName"') do set "LOCALE=%v"
Originally, I thought about a PowerShell
issue, but then found the same effect with REG QUERY
.
No idea what happened - after being back from vacation, everything works as before, though nothing changed in the meantime. I will keep an eye on the issue and add here if something changes again, but for now, I close it.