November 22, 2013
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
Python
1 2 3 |
<span style="color: #008000;">#define NT_STATUS_SERVICE_DOES_NOT_EXIST NT_STATUS(0xc0000424)</span> to: <span style="color: #008000;">#define NT_STATUS_SERVICE_DOES_NOT_EXIST NT_STATUS(0x00000424)</span> |
- You might need to manually install the winexe service on the target windows machine by applying the following commands:
Python
1 2 3 4 |
<span style="color: #008000;">sc create winexesvc binPath= C:\WINDOWS\WINEXESVC.EXE start= auto DisplayName= winexesvc sc description winexesvc "Server Monitoring Tool"</span> |
About Author
Mohammed Abualrob
Software Engineer @ Cisco
One Comment
Thank you very much for post on Winexe Installation