首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用winexe在Windows机器上运行"wmic“命令

使用winexe在Windows机器上运行"wmic“命令
EN

Unix & Linux用户
提问于 2013-07-12 20:41:56
回答 1查看 11.7K关注 0票数 3

我们使用winexe在Linux的Windows机器上执行命令。例如:

代码语言:javascript
复制
winexe -A authfile //syspc4.domain.com "ipconfig /all"

预期上面的输出结果与您在Windows计算机上运行cmd.exe并输入"ipconfig /all“相同。

我的最终目标是远程(从Linux)获取窗口的机器序列号和型号名称。在Windows (Windows )机器上本地使用cmd.exe中的以下两个命令很容易实现这一点:

代码语言:javascript
复制
wmic bios get serialnumber
wmic computersystem get model

然而,任何通过winexe执行此操作的尝试都不起作用--在按回车之后,什么也不会发生。没有错误,什么都没有。它只会被冻结,直到我ctrl+c离开它。

下面是我尝试过的命令:

代码语言:javascript
复制
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/

编辑:打开调试后,它就挂在这里:

代码语言:javascript
复制
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),它也提供了完全相同的内容:

代码语言:javascript
复制
...
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
EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2013-09-19 20:32:47

在这里使用WMI-Client:http://www.orvant.com/packages/并直接从Linux运行WMIC命令,尽管您必须使用命令的WQL等价物,因为这个版本不支持非WQL查询。

票数 3
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/82825

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档