0

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!

Tom Dong
  • 79
  • 6
  • Is this any help, use exec task and read output? http://stackoverflow.com/questions/4344139/how-to-get-a-return-value-from-an-exec-in-ant-script – Whome Apr 02 '15 at 12:21
  • 1
    To me, the single quotes look suspicious. Are they suppose to show inner and outer quotes? You can use HTML entity `"` for double quotes, and `'` for single quotes. Will that help? – David W. Apr 02 '15 at 12:56

1 Answers1

0

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
Serenity
  • 9
  • 3