Run windows commands from linux

Is it possible to run Windows commands using rdesktop tool in Linux? I tried with rdesktop -s option:

rdesktop -u user -p 10.0.0.2 -s "cmd.exe"

but I’m not able to open the cmd.exe using the above command, also I tried with the full path:

rdesktop -u user -p'password' 10.0.0.2 -s "C:\WINDOWS\system32\cmd.exe"

but there is no difference in the RDP session even if I use -s.

I’m trying to get a list of RDP sessions using qwinsta /server in Windows from Linux.

slm's user avatar

slm

365k119 gold badges768 silver badges872 bronze badges

asked Dec 3, 2014 at 20:04

Augustin's user avatar

3

If you have access to the computer, install an ssh server on it.
On Linux you can use for example Overlook-Fing to find the IP of the computer.
Then you type
ssh username@ipaddress into the Linux shell.

Example:

ssh [email protected]

Then type the user’s password and you should have access to the computer’s Windows Command Prompt.
You could also use telnet but ssh is encrypted.

answered Aug 29, 2016 at 11:04

aka91x's user avatar

aka91xaka91x

691 silver badge2 bronze badges

I don’t have a solution using rdesktop but I use a program called winexe on Linux to execute remote commands on Windows machines. You can get the application from the following URL or use your distribution’s software repository system to install it.

http://sourceforge.net/projects/winexe/

UPDATE: SSL cert is self signed for the sourceforge link above, so I’m providing another link:

https://github.com/skalkoto/winexe

Here’s an example of the usage:

winexe -A credentials.cfg //remotehost "qwinsta /server"

You will want to create a credentials.cfg file with the login information as so:

username=user
password=pass
domain=workplace

Only supply the domain if it applies to you. It’s a best practice to not put your login credentials (especially password) on the command line. Try running cmd.exe using the example above if you want an interactive prompt. Nice thing about this approach is that you can use the output of the remote command in your Linux scripts or grep the output.

answered Dec 3, 2014 at 23:20

cmevoli's user avatar

cmevolicmevoli

4514 silver badges4 bronze badges

3

As of today, you could use xfreerdp with it’s RemoteApp feature to execute specific software:

  1. Enable RemoteApps on a Windows host. Should be as easy as editing registry;
  2. Install xfreerdp on your Linux host. There are ready-to-use builds for Ubuntu, Debian, Fedora, OpenSUSE and macOS.
  3. Execute the command xfreerdp /u:user /d:domain /p:password /app:"||calc" /v:server where:
    • /u:— Windows user
    • /d:— Domain(could be WORKGROUP if not joined an AD)
    • /p:— Windows password
    • /app:"||calc" — App to be executed. Could be cmd as you want
    • /v:— IP address or Hostname of the Windows host.

answered Feb 27, 2018 at 11:26

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

Native solution

The official solution provided with Windows 10 Insider Preview Update (14951) is based on the almost forgotten binfmt_msc Linux facility for launching binaries. The registration command for the binfmt_misc would be like this (where /init is the provisional binfmt_misc «interpreter» for the win-executables):

sudo echo ":WSLInterop:M::MZ::/init:" > /proc/sys/fs/binfmt_misc/register

And then win-executable would be launched like regular programs:

$ export PATH=$PATH:/mnt/c/Windows/System32
$ notepad.exe
$ ipconfig.exe | grep IPv4 | cut -d: -f2
$ ls -la | findstr.exe foo.txt
$ cmd.exe /c dir

Not that any win-executable must reside in the windows (DrvFs) file-system — not on the Linux’s file-system (VolFs) — in order to inherit a proper Windows working-directory.

The cbwin alternative

Untill you get the latest build, project cbwin offers a workaround, by installing 3 new linux commands inside WSL:

  • wcmd: call a win-executable through cmd.exe.
  • wrun: call a win-executable synchronously with CreateProcess, and wait to die (not using cmd.exe).
  • wstart: launch a detached (asynchronously) command (with the use of cmd.exe).

In order to use them, you must:

  1. Install cbwin:
    • a new outbash.exe will be installed in your regular Windows filesystem (somewhere in your %PATH%), plus
    • the 3 linux-commands in the WSL filesystem.
  2. Use this outbash.exe (wherever you installed it) to start WSL, NOT C:\Windows\System32\bash.exe!
  3. Prefix any win-executables with one of those commands, e.g. wrun notepad.

Tip: If the executable launched with wcmd or wrun spawns any children, these survive only for as long that executable remains alive.

In other words, trying to start notepad.exe with wcmd won’t work, because notepad will be killed just after having been launched — Use wrun (synchronously) or wstart (asynchronously) in this case.

Asked

Viewed
16k times

How to access the windows command line from an ubuntu machine.
OS in question is Windows 7 and Ubuntu 12.04.
Accessing here refers to remote access.

asked Dec 25, 2013 at 4:54

Rohan Majumdar's user avatar

1

Several ways:

  1. Run an ssh server on the Windows host, and connect to it with an ssh client. There are lots of ssh servers that you can buy for Windows, but Cygwin includes the free OpenSSH server. However, that will get you a Linux shell when you connect to it.

  2. Run Windows Terminal Services, and connect to it with a Remote Desktop client. That will give you a remote desktop, where you can start a Windows command line, Cygwin shell, or any other programs.

  3. Run the Windows telnet service, and connect to it with a telnet client.

answered Dec 25, 2013 at 6:37

Andrew Schulman's user avatar

Andrew SchulmanAndrew Schulman

8,82121 gold badges33 silver badges47 bronze badges

8

Set up a Windows 2012 server as a Powershell Remote Access gateway. Connect to powershell on the gateway and execute remote powershell commands on other machines such as your Windows 7 machine.

If you want a native telnet like remote commandline then install telnet (I’m not saying it is a good solution, just a solution) or a third party solution. Execute powershell commands from within cmd.exe, there are quite a few options for doing that. I suggest to google to your hearts content.

Community's user avatar

answered Dec 25, 2013 at 7:27

ErikE's user avatar

ErikEErikE

4,7561 gold badge20 silver badges27 bronze badges

Not the answer you’re looking for? Browse other questions tagged

.

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

<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:

<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

If you have access to the computer, install an ssh server on it. On Linux you can use for example Overlook-Fing to find the IP of the computer. Then you type ssh username@ipaddress into the Linux shell. Then type the user’s password and you should have access to the computer’s Windows Command Prompt.

How do I run Unix commands in Windows?

If you are just looking to practice Linux to pass your exams, you can use one of these methods for running Bash commands on Windows.

  1. Use Linux Bash Shell on Windows 10.
  2. Use Git Bash to run Bash commands on Windows.
  3. Using Linux commands in Windows with Cygwin.
  4. Use Linux in virtual machine.

Can I connect to Windows machine from Linux shell?

VNC can be run from a stand-alone binary or installed. For RDP most Linux systems either already have rdesktop installed or it is available in the package manager. Using rdesktop you only have to enable RDP connections to your Windows system and then you will be able to use RDP for a full GUI Windows console.

How do I connect my Unix machine to Windows?

Start SSH and Log In to UNIX

  1. Double-click the Telnet icon on the desktop, or click Start> Programs> Secure Telnet and FTP> Telnet.
  2. At the User Name field, type your NetID and click Connect.
  3. An Enter Password window will appear.
  4. At the TERM = (vt100) prompt, press .
  5. The Linux prompt ($) will appear.

How do I run a Windows script in Linux?

Run Windows tools from Linux WSL can run Windows tools directly from the WSL command line using [tool-name].exe . For example, notepad.exe . Applications run this way have the following properties: Retain the working directory as the WSL command prompt (for the most part — exceptions are explained below).

Do Unix commands work in Windows?

commands within your Windows scripts to add functionality and ease to your tasks. The beauty of cygwin is that you can use Unix commands to work on files on Windows systems.

Is Windows Unix command?

cmd.exe is the counterpart of COMMAND.COM in DOS and Windows 9x systems, and analogous to the Unix shells used on Unix-like systems. The initial version of cmd.exe for Windows NT was developed by Therese Stowell. The ReactOS implementation of cmd.exe is derived from FreeCOM, the FreeDOS command line interpreter.

How do I install RDP on Linux?

Install a desktop environment on your Linux VM

  1. ssh [email protected].
  2. sudo apt-get update sudo apt-get -y install xfce4 sudo apt install xfce4-session.
  3. sudo apt-get -y install xrdp sudo systemctl enable xrdp.
  4. echo xfce4-session >~/.xsession.
  5. sudo service xrdp restart.
  6. sudo passwd azureuser.

How do I install Chrome Remote Desktop on Linux?

You can set up remote access to your Mac, Windows, or Linux computer.

  1. On your computer, open Chrome.
  2. In the address bar, enter remotedesktop.google.com/access .
  3. Under “Set up Remote Access,” click Download .
  4. Follow the onscreen directions to download and install Chrome Remote Desktop.

How do I install Unix on Windows 10?

To install a distribution of Linux on Windows 10, use these steps:

  1. Open Microsoft Store.
  2. Search for the Linux distribution that you want to install.
  3. Select the distro of Linux to install on your device.
  4. Click the Get (or Install) button.
  5. Click the Launch button.
  6. Create a username for the Linux distro and press Enter.

How do I log into a Unix machine?

Log into Unix

  1. At the Login: prompt, enter your username.
  2. At the Password: prompt, enter your password.
  3. On many systems, a page of information and announcements, called a banner or “message of the day” (MOD), will be displayed on your screen.
  4. The following line may appear after the banner: TERM = (vt100)

How to access a UNIX machine from Windows command?

COM2 is, by default, configured in a way that works well for a terminal (instead of well for the NT kernel debugger.) In later versions of Hyper-V, you can configure the COM port by using the following PowerShell command. In earlier versions, COM2 is the only COM port that will work for you.

Is it possible to run Linux commands on Windows?

Yes, it will save a lot of work! Here are some ways to run Linux commands on Windows. Step 1: Go to Update and Security in Settings. Step 2: Go to the Developer’s Mode and Select the Developer’s Mode option. Step 3: Open the Control Panel. Step 4: Click Programs and Features. Step 5: Click Turn Windows Features On or Off.

How to execute Windows commands remotely from Linux machine?

If you have access to the computer, install an ssh server on it. On Linux you can use for example Overlook-Fing to find the IP of the computer. Then you type ssh username@ipaddress into the Linux shell. Then type the user’s password and you should have access to the computer’s Windows Command Prompt. You could also use telnet but ssh is encrypted.

Which is the best way to install Linux?

Another way is to use a virtualization software and install Linux in it. This way, you install a Linux distribution (with graphical interface) inside Windows and run it like a regular Windows application. This method requires that your system has a good amount of RAM, at least 4 GB but better if you have over 8 GB of RAM.

  • Rufus скачать для windows 10 x64
  • Run a command as admin in windows
  • Rufus скачать бесплатно на русском языке для windows 10 64 bit через торрент
  • Rufus скачать бесплатно на русском языке для windows 10 64 bit торрент для windows
  • Rufus скачать бесплатно на русском языке для windows 10 64 bit с официального сайта