You are currently viewing Run commands on the Windows system remotely using Winexe
winexe working example

Run commands on the Windows system remotely using Winexe

  • Post author:
  • Reading time:3 mins read

Run commands on the Windows system remotely using Winexe:
Winexe is a GNU/Linux-based application that allows users to execute commands remotely on WindowsNT/2000/XP/2003/Vista/7/8 systems. Moreover, it installs a service on the remote system, executes the command, and uninstalls the service. Windows Winexe allows the execution of most of the Windows shell commands. This can be easily done by using a Patch Management System.

How to install:
You can download the source package from here [Current version is winexe-1.00.tar.gz]

  1. tar -xvf winexe-1.00.tar.gz
  2. cd winexe-1.00/source4/
  3. ./autogen.sh
  4. ./configure
  5. make basics bin/winexe
  6. make “CPP=gcc -E -freestanding” basics bin/winexe (For X64 bit)

this will create a [ winexe ] binary file in the bin folder. You can use that binary to execute the Windows commands from Linux.

or else some compiled version of the binary is available for download. You can download and use it from here.

How to use it:

  • ./winexe -U [Domain/]User%Password //host command

Examples:

  • ./winexe -U HOME/Administrator%Pass123 //192.168.0.1 “netstat -a”
  • ./winexe -U HOME/Administrator%Pass123 //192.168.0.1 “ipconfig -all”
  • /winexe -U HOME/Administrator%Pass123 //192.168.0.1 “ping localhost”

To launch a Windows shell from inside your Linux box. Using this below command,

/winexe -U HOME/Administrator%Pass123 //192.168.0.1 “cmd.exe”

winexe command execution

Winexe Binarycd winexe-1.00/source4/

SanerNow Endpoint Management 
With SanerNow Endpoint Management, you can run commands and scripts remotely, additionally keeping your workforce fully secure. Gain complete visibility and control with SanerNow.

Share this article

This Post Has 9 Comments

  1. Prakash

    Nice Tutorial !..

    It helps me right the way !…

    Can you please let me know the procedures to do the same in MAC OS X

    Cheers… 🙂

  2. Thanga Prakash

    The above mentioned procedure will work on MAC also
    But, Before install u need to change the following line

    struct tevent_context *ev_ctx; –to–> extern struct tevent_context *ev_ctx;
    in source4/winexe/winexe.h file.

  3. Alexander M

    I do the above, but I get ./auth/kerberos/krb5_init_context.h:22:2: error: unknown type name ‘krb5_log_facility’ errors. Any thoughts on these?

  4. ravi kotaru

    Excellent. this is what we are looking for. Thanks for sharing the information about the tool and the tutorial

  5. William Peckham

    When will there be a version to support Windows Server in the 2012 R2+ versions?

  6. Keerthi

    Nice Tutorial!

    Can you please let me know how would I execute a cd command on windows machine from a linux server using winexe?

    I tried this from a linux machine

    ./winexe -U ablocaluser%abcd321 //mycomputer “cd c:\tmp”

    I’m getting the following error:
    Error: error Creating process(cd c:\tmp) 2

    ./winexe -U ablocaluser%abcd321 //mycomputer “pushd c:\tmp”

    I’m getting the following error:
    Error: error Creating process(pushd c:\tmp) 2

    Also I have a tar command to untar a file

    and when I provide it via winexe command it untar the file in C:\Windows\System32 folder. I would like the contents of the tar file to be untared in a different location.

    I even tried it explicitly specifying

    ./winexe -U ablocaluser%abcd321 //mycomputer “tar -xvf sample.tar – C c:\tmp”

    but for some reason it is trying to cd to c:\Windows\System32\c:\tmp

    Appreciate your help in resolving this issue!

  7. Mangesh

    Hi Keerthi,

    Did you get any updates on ./winexe -U ablocaluser%abcd321 //mycomputer “tar -xvf sample.tar – C c:\tmp”

    I have some problem. Appreciate your help.

    Regards,
    Mangesh

  8. Sourabh

    syntax error at heimdal/cf/make-proto.pl line 15, near “do Getopts(”
    Execution of heimdal/cf/make-proto.pl aborted due to compilation errors.
    data.mk:195: recipe for target ‘heimdal/lib/asn1/der-protos.h’ failed
    make: *** [heimdal/lib/asn1/der-protos.h] Error 255

    I am getting this error. Any solution to resolve this?

  9. ipguy

    for macos you can do the below

    winexe -U workgroup/username%password //ipaddress ‘cmd.exe ‘

    make sure there is a space after exe and ‘

Comments are closed.