Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

We use winexe to execute commands on our Windows machines from Linux. For example:

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

Expectedly the above prints out the same thing as if you had run cmd.exe on a Windows machine and typed in "ipconfig /all"

My ultimate goal is to remotely (from Linux) get the Window's machines serial number and model name. This is very easily achievable with the following two commands in cmd.exe locally on the Windows (Windows XP) machine:

wmic bios get serialnumber
wmic computersystem get model

However, any attempts to execute this via winexe simply do not work --- after hitting enter, nothing happens. No error, nothing. It will just appear to be frozen until I ctrl+c out of it.

Here are the commands that I've tried:

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

In all cases, no response. A quick look at winexe --help reveals a log option, but even with that set, there is no output log of any kind.

I found the following post on another forum, in which the person is asking almost the exact same thing as me, and naturally he just never got an answer: http://www.linuxquestions.org/questions/linux-software-2/winexe-780343/

EDIT: With debug turned on, this is where it hangs:

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

However the curious thing is that even with a command that doesn't fail (like ipconfig /all), it gives the exact same thing:

...
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
share|improve this question
    
Did you ever figure this out? –  senorsmile Oct 11 '13 at 17:42
    
No, unfortunately I never did. The answer below for WMI-Client looks promising. Unfortunately we needed the solution around the time of posting, and ultimately just ended up doing the work by hand. –  CptSupermrkt Oct 18 '13 at 13:12
    
I compiled the new winexe from git yesterday (it says version 1.1) and get the exact same errors and issue with it waiting with it requiring to press enter to continue the script. –  senorsmile Nov 6 '13 at 18:41
    
This seems to be a recently reopened bug that the devs are at least aware of: sourceforge.net/p/winexe/bugs/31/?page=1. –  senorsmile Nov 6 '13 at 18:50
add comment

3 Answers

up vote 3 down vote accepted

Use the WMI-Client here: http://www.orvant.com/packages/ and run the WMIC commands directly from Linux, although you will have to use the WQL equivalents of your commands, as this version does not support the non-WQL queryies.

share|improve this answer
    
My use for this has long passed, but it looks promising. I'll mark it as the answer. If some poor soul years from now finds this via Google and it doesn't work, please leave a comment about your experience/whether it really worked or not. –  CptSupermrkt Oct 18 '13 at 13:14
    
I am trying out wmi-client (if I can ever get it to compile on Arch Linux). I'll post back my results. –  senorsmile Nov 1 '13 at 22:19
add comment

The latest winexe code (from the "current" git repository, a.k.a. "winexe-waf"; date November 2013) doesn't hang when I test it. I build winexe on Debian Wheezy with Samba 4.0.10 packages from Unstable and run winexe -U "<user>%<pwd>" //192.168.1.2 'wmic bios get serialnumber' where 192.168.1.2 is the IP address of a VirtualBox virtual machine running Windows 7 Professional SP1. Output is as follows.

$ winexe -U "<user>%<pwd>" //192.168.1.2 'wmic bios get serialnumber'
SerialNumber
0

$ winexe -U "<user>%<pwd>" //192.168.1.2 'wmic computersystem get model'
Model
VirtualBox
share|improve this answer
add comment

I'd try those command with winexe's debug switch turned on. You can turn up the debug level (looks to be a number such as 0,1,2,3,etc.).

Example

Here I'm just running your command as is except I've added the switch -d 3.

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

ERROR: Unable to open credentials file!
[param/loadparm.c:587:init_globals()] Initialising global parameters
[param/loadparm.c:2462:lp_load()] lp_load: refreshing parameters from /dev/null
[param/params.c:556:pm_process()] params.c:pm_process() - Processing configuration file "/dev/null"
[param/loadparm.c:1343:lp_add_hidden()] adding hidden service IPC$
[param/loadparm.c:1343:lp_add_hidden()] adding hidden service ADMIN$
[auth/credentials/credentials_krb5.c:171:cli_credentials_set_ccache()] failed to get principal from default ccache: No such file or directory: open(/tmp/krb5cc_500): No such file or directory
[winexe/winexe.c:304:main()] winexe version 0.80
This program may be freely redistributed under the terms of the GNU GPL
[auth/auth.c:447:auth_register()] AUTH backend 'winbind_samba3' registered
[auth/auth.c:447:auth_register()] AUTH backend 'winbind' registered
[auth/auth.c:447:auth_register()] AUTH backend 'name_to_ntstatus' registered
[auth/auth.c:447:auth_register()] AUTH backend 'fixed_challenge' registered
[auth/auth.c:447:auth_register()] AUTH backend 'unix' registered
[auth/auth.c:447:auth_register()] AUTH backend 'anonymous' registered
[auth/auth.c:447:auth_register()] AUTH backend 'sam' registered
[auth/auth.c:447:auth_register()] AUTH backend 'sam_ignoredomain' registered
[auth/gensec/gensec.c:1229:gensec_register()] GENSEC backend 'krb5' registered
[auth/gensec/gensec.c:1205:gensec_register()] gensec subsystem fake_gssapi_krb5 is disabled
[auth/gensec/gensec.c:1229:gensec_register()] GENSEC backend 'schannel' registered
[auth/gensec/gensec.c:1229:gensec_register()] GENSEC backend 'spnego' registered
[auth/gensec/gensec.c:1205:gensec_register()] gensec subsystem gssapi_spnego is disabled
[auth/gensec/gensec.c:1229:gensec_register()] GENSEC backend 'gssapi_krb5' registered
[auth/gensec/gensec.c:1229:gensec_register()] GENSEC backend 'gssapi_krb5_sasl' registered
[auth/gensec/gensec.c:1229:gensec_register()] GENSEC backend 'ntlmssp' registered
[lib/util/util.c:334:interpret_addr()] sys_gethostbyname: Unknown host. syspc4.domain.com
[lib/socket/interface.c:103:add_interface()] added interface ip=192.168.1.110 nmask=255.255.255.0
[winexe/winexe.c:322:main()] ERROR: Failed to open connection - NT_STATUS_NO_MEMORY
share|improve this answer
    
Ahhhh, it looks for a number! LOL. I tried words like "high". I'll give that a shot! –  CptSupermrkt Jul 12 '13 at 21:24
    
@CptSupermrkt - yes isn't it nice when they provide you with a program and a usage page but no man page that spells the actual details of how to "really" use it. –  slm Jul 12 '13 at 21:27
    
@CptSupermrkt - The RPM that provides that package doesn't include a cent of documentation either. Nice 8-(. –  slm Jul 12 '13 at 21:28
1  
@CptSupermrkt - I have to ask, what's Captain Supermarket? –  slm Jul 12 '13 at 21:29
2  
@CptSupermrkt - WTF? Are you serious? Thanks I'm crying from laughter. –  slm Jul 12 '13 at 21:33
show 9 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.