Advanced doskey macro writing

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
noprogrammer
Posts: 36
Joined: 29 Oct 2009 11:55

Advanced doskey macro writing

#1 Post by noprogrammer » 19 Sep 2013 09:13

Hi,

I started using a dedicated cmdinit.cmd file for my doskey macros (Windows 7x64).
Macros like

Code: Select all

alias=doskey /macros $Bsort
work fine.

I've added one macro recently that just doesn't work as expected:

Code: Select all

doskey mac=For /f "tokens$Q4 delims$Q " %%# In ('getmac/V $E$B findstr/I "lan"') Do (echo LAN: %%#)

Executing the macro, I'll receive a message that the "|" can't be processed at that position.

The part after the = sign is valid, i.e.

Code: Select all

For /f "tokens=4 delims= " %%# In ('getmac/V ^| findstr/I "lan"') Do (echo LAN: %%#)
with just the special chars =, ^, | replaced with their doskey substitutes $Q, $E, $B, but it still won't work...

Did I forget anything? :?

aGerman
Expert
Posts: 4743
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Advanced doskey macro writing

#2 Post by aGerman » 19 Sep 2013 11:04

I'm not quite certain where you found the characters $Q and $E :?
See TechNet Library

Code: Select all

doskey mac=For /f "tokens=4 delims= " %# In ('getmac/V ^^$B findstr/I "lan"') Do (echo LAN: %#)


Regards
aGerman

noprogrammer
Posts: 36
Joined: 29 Oct 2009 11:55

Re: Advanced doskey macro writing

#3 Post by noprogrammer » 01 Oct 2013 08:04

Thank you, "^^$B" works as expected.

Post Reply