0
votes

How to execute the below command in ant target with < exec > task.

wmic nic where 'netconnectionid like '%'' get netconnectionid

If I run above in command line, I can get this output:

NetConnectionID
Local Area Connection
Local Area Connection 2

However, if I call this command via this way:

<target name="test">
    <exec executable="wmic">
    <arg line="nic where 'netconnectionid like '%'' get netconnectionid"/>
    </exec>
</target>

I got below error:

[exec] Node - MyComputer
[exec] ERROR:
[exec] Description = Invalid query
[exec]
[exec]
[exec] Result: -2147217385

Anyone can help me? Thank you!

1
Is this any help, use exec task and read output? stackoverflow.com/questions/4344139/…Whome
To me, the single quotes look suspicious. Are they suppose to show inner and outer quotes? You can use HTML entity &quot; for double quotes, and &apos; for single quotes. Will that help?David W.
Thank you @David W. you solved my problem!!!Tom Dong

1 Answers

0
votes

80041017 is your error number. numbers greater than 80040200 are component specific errors (and a general OLE errors under 0x80040200).

WBEMDisp.h says this

wbemErrInvalidQuery = 0x80041017

But your query is for EVERYTHING, so you can omit your where alltogether.

wmic nic get netconnectionid