I have this command
for /F "tokens=2 delims=:" %a in ('ipconfig ^| findstr /R "Default Gateway[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"') do @ping -t %a
this works fine and extracts my default gateway and pings it
I would like to wrap this into a doskey macro called pig (aka ping gateway), but can not escape the findstr correctly. The doskey looks like this (^^ is needed to escape the pipe)
doskey pig = for /F "tokens=2 delims=:" %a in ('ipconfig ^^| findstr /R "Default Gateway[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"') do @ping -t %a
With this however the doskey does not even register and findstr generates this output
FINDSTR: Cannot open do
FINDSTR: Cannot open @ping
FINDSTR: Cannot open -t
FINDSTR: Cannot open %a
I found out that escaping the last double quote allows for registering the doskey, but if I call the pig, it just outputs this:
More?
My imagination ends here and the machine just asks me for more...
I would like to have a doskey macro which looks up the gateway and pings it for me