How do I do this with a multiple-line DO?

May 20, 2008
11,520
102
Syracuse, NY, USA
From the command line ...

Code:
v:\> do line in /p `wmic /Node:"zz" path win32_groupuser where (groupcomponent="win32_group.name=\"administrators\",domain=\"zz\"")` ( echo %line )
GroupComponent                                 PartComponent
win32_group.domain="zz",name="administrators"  \\ZZ\root\cimv2:Win32_UserAccount.Domain="zz",Name="Administrator"
win32_group.domain="zz",name="administrators"  \\ZZ\root\cimv2:Win32_UserAccount.Domain="zz",Name="vefatica"
win32_group.domain="zz",name="administrators"  \\ZZ\root\cimv2:Win32_SystemAccount.Domain="ZZ",Name="NETWORK SERVICE"
win32_group.domain="zz",name="administrators"  \\ZZ\root\cimv2:Win32_SystemAccount.Domain="ZZ",Name="LOCAL SERVICE"

In a BTM ...

Code:
v:\> type wmictest.btm
do line in /p `wmic /Node:"zz" path win32_groupuser where (groupcomponent="win32_group.name=\"administrators\",domain=\"zz\"")`
        echo %line
enddo

v:\> wmictest.btm
Invalid WHERE Syntax.
ECHO is OFF
TCC: V:\wmictest.btm [3]  Unknown command "enddo"

How do I get the multi-line version to work in a BTM?
 

samintz

Scott Mintz
May 20, 2008
1,511
18
Solon, OH, USA
I put the command into a variable then expand the variable in the DO.
Code:
set wm=wmic /Node:"zz" path win32_groupuser where (groupcomponent="win32_group.name=\"administrators\",domain=\"zz\"")
do line in /p %[wm]
 
May 20, 2008
11,520
102
Syracuse, NY, USA
I put the command into a variable then expand the variable in the DO.
Code:
set wm=wmic /Node:"zz" path win32_groupuser where (groupcomponent="win32_group.name=\"administrators\",domain=\"zz\"")
do line in /p %[wm]
Yeah, but why is any masaging needed?
 

rconn

Administrator
Staff member
May 14, 2008
12,404
152
The single back quotes are removed before DO is called.

DO is then looking for a trailing command group, and it finds one starting with "(groupcomponent=…" Your line works with the single-line DO because you have *another* trailing command group to satisfy DO.
 
May 20, 2008
11,520
102
Syracuse, NY, USA
The single back quotes are removed before DO is called.

DO is then looking for a trailing command group, and it finds one starting with "(groupcomponent=…" Your line works with the single-line DO because you have *another* trailing command group to satisfy DO.
Is there a way to make it work?
 
Similar threads
Thread starter Title Forum Replies Date
MickeyF TCC crashing when copying multiple files (now resolved) Support 6
N Unable to bind multiple keys to the same key mapping directive Support 9
vefatica Console not redrawn in BTM or with multiple commands Support 4
C duplicate files in multiple plugin sites Support 9
kb6ojs ALIAS with multiple commands? Support 9
Joe Caverly Multiple Text Searches at once using FFIND or TPIPE Support 4
R How to? Append files in multiple subfolders using copy? Support 8
N multiple command alias and redirection Support 0
B Can copy command concatenate multiple mp3 files Support 2
C INSTALLED returnes same program multiple times Support 14
M Delete multiple Alternate Datastreams Support 5
D What are the rules for detecting multiple versions of TC on a machine? Support 7
C FOLDERMONITOR inactive with multiple /I Support 1
C WAD VIEW print multiple files - switches fail Support 10
vefatica Multiple instances of help file Support 3
J How to? Array sort according to multiple keys Support 3
Alexander WAD The number of files and dirs are multiplied when using multiple wildcards Support 6
Jay Sage Version 17 Installer Leaves Multiple Copies of ShrAlias Support 48
R Fixed Internal ZIP command fails to process multiple files Support 3
M How to? PDir on multiple wildcard patterns... Support 2
A WAD Dir daterange + multiple path wildcards crashes tcc Support 2
T How to? Using FOLDERMONITOR 1 event causes multiple trigger(ing)s Support 8
samintz How to? Pull out multiple matching lines Support 5
D WAD Multiple TEE causese weird variable scoping? Support 7
L "for" in multiple lines Support 2
S TAR with multiple files and /G Support 2
Frank VIEWing multiple files possible? Support 4
J syntax problems multiple commands (command & command) Support 4
J How do I - ffind - with multiple items Support 10
R multiple monitor 'help' Support 7
H Another multiple FTP password prompt issue Support 2
J tcmd height with multiple monitors Support 2
T Open & Configure multiple TCC windows on STARTUP Support 4
C blank line in copy ... results Support 9
old coot LEAVE appears to affect command-line arguments Support 11
T VIEW only works from command line Support 14
vefatica `Back quotes` - command line vs. batch file Support 5
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
D How to use multi-line DO to loop through first level directory names Support 5
D Open Windows 10 Photos app from command line Support 11
Peter Murschall Single-line Do-CMD is a bit uncooperative. Support 6
Jesse Heines Strange Line Wrapping Behavior Support 14
fpefpe How to? command echo in title line/bar Support 2
vefatica Command line DO with no closing parenthesis? Support 9
R Long commands retrieved from command history have blank line when wrapped Support 20
M No line wraps if last line of the screen buffer is reached Support 5
Joe Caverly No blank line in TEXT...ENDTEXT in a LIBRARY function Support 8
R CMDebug, dark theme, current line Support 7
vefatica IDE - when breakpoint is on a blank line? Support 3

Similar threads