Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

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

May
12,846
164
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?
 
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]
 
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?
 
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

Back
Top