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

May 20, 2008
10,568
78
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,413
13
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
10,568
78
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
11,910
133
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
10,568
78
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?