Trying to run the following directly from the command prompt.
FOR /f "delims= tokens=2" %%a in ('ping %computername% -4 -n 1 ^| findstr "["') do (set ip=%%a)
While it runs fine from within a batch file, if run pasted directly into a command prompt, I get the following error:
%%a was unexpected at this time.
How do I need to change it to work directly from the command prompt and NOT require a batch file?
Long story requirements:
I have a requirement of basically providing a list of commands that can be run via copy/paste into a command prompt, WITHOUT using a batch file (just go with it, not my requirements but those given to me and can't be budged). I have a later command that would echo %ip% to a .txt file.