Support Wikipedia Follow My Heart: WMIC Examples

2011年10月5日星期三

WMIC Examples

I copied this post from Support.Microsoft



























2 条评论:

  1. If you want to use Java Runtime.exec() to run the WMIC command, please remember that :
    1, you must write your command as "CMD /c WMIC ..." format. WMIC cannot work correctly if been invoked directly.

    2, Do not forget to add "<NUL" at the end of command, otherwise your process never return sometimes.

    回复删除
  2. I found the reason why Java programmers should add "<NUL" in the end of Command String. It is : "<NUL" will force the process to close its outputStream (for WMIC, what will be closed is its inputstream).

    So you have an alternative: to explicitly run the this command ("process.getOutputStream().close()") after you redirect the inputstream to your own logs.

    回复删除