winexeを使用してWindowsシステムで「wmic」コマンドを実行する

winexeを使用してWindowsシステムで「wmic」コマンドを実行する

winexeを使用してLinuxのWindowsシステムでコマンドを実行します。たとえば、

winexe -A authfile //syspc4.domain.com "ipconfig /all"

上記は、Windowsシステムでcmd.exeを実行し、「ipconfig / all」と入力したのと同じ内容を印刷すると予想されます。

私の究極の目標は、Windowsシステムのシリアル番号とモデル名をリモートで(Linuxで)取得することです。これは、Windows(Windows XP)システムのローカルcmd.exeで次の2つのコマンドを使用して簡単に実行できます。

wmic bios get serialnumber
wmic computersystem get model

ただし、winexeを介してこのコマンドを実行しようとすると機能しません。 Enterキーを押した後は何も起こりません。エラーもなく、何もありません。 ctrl + cを押して終了するまで停止したようです。

私が試したコマンドは次のとおりです。

winexe -A authfile //syspc4.domain.com "wmic bios get serialnumber"
winexe -A authfile //syspc4.domain.com "cmd wmic bios get serialnumber"
winexe -A authfile //syspc4.domain.com "cmd /c wmic bios get serialnumber"
winexe -A authfile //syspc4.domain.com "cmd"
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\WINDOWS\system32>wmic bios get serialnumber

すべての場合に応答がありません。 winexe --helpを少し見てみると、ロギングオプションが表示されますが、そのオプションを設定しても何らかの出力ログはありません。

誰かがかなり多くの質問をした他のフォーラムで、次のスレッドを見つけました。精密私のように彼も当然答えを得ませんでした。 http://www.linuxquestions.org/questions/linux-software-2/winexe-780343/

編集する:デバッグがオンの場合、ここで中断されます。

winexe -d 6 -A authfile //syspc4.domain.com "wmic bios get serialnumber"

...
IN: async_open(\pipe\ahexec, 2)
IN: async_open_recv
CTRL: Sending command: get version
CTRL: Sending command: run wmic bios get serialnumber
CTRL: Recieved command: std_io_err 15C40030
IN: async_open(\pipe\ahexec_stdin15C40030, 2)
IN: async_open(\pipe\ahexec_stdout15C40030, 2)
IN: async_open(\pipe\ahexec_stderr15C40030, 2)
IN: async_open_recv
IN: async_open_recv
IN: async_open_recv

**hangs forever here**

Then ctrl+c:

^CAborting...
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: on_ctrl_pipe_error - NT_STATUS_PIPE_DISCONNECTED

しかし、奇妙なことは、コマンドが失敗しなくても(例えばipconfig / all)、まったく同じ結果が出るということです。

...
IN: async_open(\pipe\ahexec, 2)
IN: async_open_recv
CTRL: Sending command: get version
CTRL: Sending command: run ipconfig /all
CTRL: Recieved command: std_io_err 15C40031
IN: async_open(\pipe\ahexec_stdin15C40031, 2)
IN: async_open(\pipe\ahexec_stdout15C40031, 2)
IN: async_open(\pipe\ahexec_stderr15C40031, 2)
IN: async_open_recv
IN: async_open_recv
IN: async_open_recv

Windows IP Configuration
...
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: on_ctrl_pipe_error - NT_STATUS_PIPE_DISCONNECTED

ベストアンサー1

WMI クライアントはここで使用されます。http://www.orvant.com/packages/Linux で直接 WMIC コマンドを実行できます。ただし、このバージョンは非WQLクエリをサポートしていないため、WQLコマンドと同等のコマンドを使用する必要があります。

おすすめ記事