Execute Windows command from Linux

Winexe can be used to invoke remote Windows commands from Unix based system like Linux. Follow the steps below to build and install Winexe…

installation Steps

  • Download winexe from sourceforge
  • Copy source code to the linux machine for example: scp winexe-1.00.tar.gz user@linuxhost:/path/to/winexe
  • ssh to the linux machine and extract the package you just uploaded in the previous step
  • Go to source directory (for example cd source4)
  • sudo apt-get install build-essential autoconf checkinstall
  • wget https://gist.github.com/raw/843062/5bb87c4fa13688f65ca8b1e54fc42676aee42e5a/fix_winexe_service.diff
  • patch -p0 -i fix_winexe_service.diff
  • ./autogen.sh
  • ./configure
  • make basics bin/winexe
  • sudo cp bin/winexe /usr/local/bin/

Syntax

The command syntax is: winexe -U DOMAIN/Administrator //server-name ‘command to execute’. Here is an example how to invoke the command: winexe -U mydomain/Administrator //windows-machine ‘ipconfig’ It will prompt you for a Windows password then prints the ipconfig information.

Notes

  • If the patch did not work with you then you might need to manually edit the file service.c and change

  • You might need to manually install the winexe service on the target windows machine by applying the following commands:

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *