Top 10 winexe Example to run powershell script from Linux

Top 10 winexe examples  to run PowerShell or Batch script from Linux

This Article is about the Winexe Examples, Winexe remotely executes commands on Windows NT/2000/XP/2008/2012 systems from Linux systems. Download Winexe hare. In Daily Automation task we need to communicate so many time from Linux to Windows vice versa. WinExe is a easy to use tool which solved this challenge with some simple commands In this article i cover some of the examples for WinExe.
winexe – Remote Windows-command executor
[root@onclick ~]# winexe --help
winexe version 1.1
This program may be freely redistributed under the terms of the GNU GPLv3
Usage: winexe [OPTION]... //HOST COMMAND
  -?, --help                                  Display help message
  -U, --user=[DOMAIN/]USERNAME[%PASSWORD]     Set the network username
  -A, --authentication-file=FILE              Get the credentials from a file
  -k, --kerberos=STRING                       Use Kerberos, -k [yes|no]
  -d, --debuglevel=DEBUGLEVEL                 Set debug level
      --uninstall                             Uninstall winexe service after remote execution
      --reinstall                             Reinstall winexe service before remote execution
      --system                                Use SYSTEM account
      --profile                               Load user profile
      --convert                               Try to convert characters between local and remote code-pages
      --runas=[DOMAIN\]USERNAME%PASSWORD      Run as user (BEWARE: password is sent in cleartext over net)
      --runas-file=FILE                       Run as user options defined in a file
      --interactive=0|1                       Desktop interaction: 0 - disallow, 1 - allow. If you allow use
                                              also --system switch (Win requirement). Vista do not support
                                              this option.
      --ostype=0|1|2                          OS type: 0 - 32-bit, 1 - 64-bit, 2 - winexe will decide.
                                              Determines which version (32-bit or 64-bit) of service will be
[root@onclick ~]#


winexe Usage Example

1. List Program Files folders and files.

 winexe -U HostName/Administrator%Password123 //IP Address 'dir "/Program Files"'

2. Copy file from one folder to another folder.

 winexe -U HostName/Administrator%Password123 //IP Address 'copy C:/myfile.txt C:/user/desktop/'

3. Restart server from Winexe

 winexe -U HostName/Administrator%Password123 //IP Address 'shutdown /r'

4. Check the Services status

 winexe -U HostName/Administrator%Password123 //IP Address 'sc query "ServiceName" | find "RUNNING"'

5.Run ipconfig windows command from Linux

 winexe -U HostName/Administrator%Password123 //IP Address "ipconfig /all"

6. With the given credentials (-U ‘Administrator%password123’), connect to the remote server (//IP Address), and execute the given command (‘cmd.exe /c echo “Hello World”‘):

winexe -U 'Administrator%Password123' //IP Address 'cmd.exe /c echo "Hello World"'

7. Run PowerShell commands from Linux:

  winexe -U 'Administrator%Password123' //IP Address 'powershell.exe Get-Process'

8. Run Windows Batch Script with Name argument: Create a bat file in and copy paste this code

@echo hello %1

and save to task.bat. Now call this script from Linux with below command.

 winexe -U 'Administrator%Password123' //IP Address 'cmd.exe /c "C:/folder/task.bat Name"'</pre>
Output : hello Name

Batch files can only handle parameters %0 to %9

%0 is the program name as it was called,
%1 is the first command line parameter,
%2 is the second command line parameter,
and so on till.%9
9. Run Power Shell Script from Linux using Winexe.

winexe -U" // "cmd.exe /c powershell.exe C:/folder/task.ps1"

10. Run Power Shell Script with Name argument from Linux using Winexe.

 winexe -U" // 'cmd.exe /c "powershell.exe C:/folder/task.ps1 Name"'
Hope you enjoy this article.
Top 10 winexe Example to run powershell script from Linux

Top 10 winexe examples  to run PowerShell or Batch script from Linux This Article is about the Winexe Examples, Winexe remotely executes commands

Editor's Rating:


You May Also Like

9 thoughts on “Top 10 winexe Example to run powershell script from Linux

  1. Hello.This article was extremely fascinating, particularly because I was searching for thoughts on this topic last Wednesday.

  2. I was recommended this website by means of my cousin. I am now not positive whether this put up is written by way of him as no one else recognize such distinct about my difficulty. You’re wonderful! Thank you!

  3. Hola
    Finally I found a working activator for Windows. And of course, I share it with you!

    Whatever you have been looking for for a long time, a quality and working activator – I am sharing with you

  4. Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! By the way, how can we communicate?

  5. Good site you’ve got here.. It’s hard to find high-quality writing
    like yours nowadays. I really appreciate people like you!

    Take care!!

  6. Wow! You certainly included all important points with your post. I would like to read more by you. Do you run any more blogs?

  7. Whoa! This blog looks just like my old one! It’s on a totally different topic but it has pretty much the same page layout and design. Excellent choice of colors!

  8. Hey there! Do you use Twitter? I’d like to follow you if that would be ok. I’m undoubtedly enjoying your blog and look forward to new updates.

Leave a Reply

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