Categories
Life hack

How to run windows programs from windows 10’s bash shell

How to run windows programs from windows 10’s bash shell

Since its initial release in mid-2015, Windows 10 stirred up a lot of chatter about its new and improved features in regards to the previous versions of Windows. With every major update the list of new features grew more and more.

One of the many features that got the users excited, especially linux users and developers, was the introduction of the Linux Bash Shell. Users got this feature with the Anniversary Update released on August 2nd 2016.

For the users not acquainted with this feature: this means that you will be able to execute any linux command within Windows 10 without having to run a virtual machine and install linux on it, or having to install linux as a separate operating system on your hard drive. This feature doesn’t mean that you will have a full version of linux on your Windows PC. You will only be able to execute linux commands on Windows without the need of virtual machines or emulators, courtesy of Microsoft and Canonical.

Unfortunately, the bash shell is not enabled by default on Windows 10, so in order to use it you must enable it first, and you can only get it if your Windows has the Anniversary Update or other newer versions and it will not work under older versions of Windows, such as 8/8.1, 7, Vista etc.

How to enable Linux Bash Shell on Windows 10.

1. Open settings by opening up the start menu either by clicking on the windows icon on the left of the taskbar or by using the Windows key on your keyboard

How to run windows programs from windows 10’s bash shell

2. Go to “Update & Security”

How to run windows programs from windows 10’s bash shell

3. From the left side panel select “For Developers”

How to run windows programs from windows 10’s bash shell

4. In the middle select “Developer mode”

How to run windows programs from windows 10’s bash shell

5. A window will pop up asking you if you are sure that you want to enable developer mode, due to security risks that might occur if you install applications from untrusted sources (which we will not be doing in this situation). You will need to click on “Yes”. You might need to wait a few minutes for the Developer Mode package to be installed.

How to run windows programs from windows 10’s bash shell

6. When the package installation is completed, you will need to navigate to the Control Panel. You will need to go in the start menu, either by pressing the Windows key on your keyboard or clicking the Windows icon on the left side of the taskbar, and type in “control panel”

How to run windows programs from windows 10’s bash shell

7. By default, Windows sorts the settings as categories, so in the upper right corner under “View by” you will need to select “Large Icons”

8. Once you do that, navigate to “Programs and Features”

How to run windows programs from windows 10’s bash shell

9. In the next window, from the left side click on “Turn Windows features on or off”

How to run windows programs from windows 10’s bash shell

10. On the next window you will need to scroll all the way to the bottom, tick “Windows Subsystem for Linux” and click on “OK”

How to run windows programs from windows 10’s bash shell

11. The installation process will take a few minutes, after which you will be prompted to restart your PC. Click on “Restart now” and wait for the Windows to reboot, but before you do, make sure that you have all your work saved before clicking on the restart button.

How to run windows programs from windows 10’s bash shell

12. Once Windows boots up, open up your browser and navigate to this URL: https://aka.ms/wslstore

13. The Windows store will open up where you will be able to choose which Linux flavor you like the most. In this case, we installed Ubuntu. Click on Ubuntu.

How to run windows programs from windows 10’s bash shell

14. On the next window click on “Get”. The installation process takes a couple of minutes to be completed, after which you will be notified in the notification area.

15. When the installation process is completed, you will need to click on “Launch” in the same window, which will open up a terminal like window and will start the installation process. Unlike the previous process, this one last a little bit more.

16. When the installation process is completed, in the terminal window you will need to enter a username and a password (you will be required to retype the password) after which your user will be created and you can start using the linux bash shell.

How to run windows programs from windows 10’s bash shell

Next time you want to use the linux terminal, all you would need to do is open the start menu and type in “bash”.

Frequently Asked Questions and Answers

Q: I am concerned about the security while enabling developer mode. Can I disable it?

A: The security concerns when enabling developer mode are only in situations when you install applications from untrusted sources. If you want to disable the developer mode just follow steps 1 to 4 and on the 4th step and select either “Windows Store Apps” or “Sideload Apps”

Chris Hoffman is Editor-in-Chief of How-To Geek. He’s written about technology for over a decade and was a PCWorld columnist for two years. Chris has written for The New York Times and Reader’s Digest, been interviewed as a technology expert on TV stations like Miami’s NBC 6, and had his work covered by news outlets like the BBC. Since 2011, Chris has written over 2,000 articles that have been read nearly one billion times—and that’s just here at How-To Geek. Read more.

How to run windows programs from windows 10’s bash shell

With the arrival of Windows 10’s Bash shell, you can now create and run Bash shell scripts on Windows 10. You can also incorporate Bash commands into a Windows batch file or PowerShell script.

Even if you know what you’re doing, this isn’t necessarily as simple as it seems. Windows and UNIX use different end-of-line characters, and the Windows file system is accessible in a different location in the Bash environment.

How to Write a Bash Script on Windows 10

When writing shell scripts on Windows, bear in mind that Windows and UNIX-like systems like Linux use different “end of line” characters in text files in shell scripts.

In other words, this means that you can’t simply write a shell script in Notepad. Save the file in Notepad and it won’t be interpreted properly by Bash. However, you can use more advanced text editors–for example, Notepad++ allows you to give a file UNIX end-of-line characters by clicking Edit > EOL Conversion > UNIX/OSX Format.

How to run windows programs from windows 10’s bash shell

However, you’re better off just writing the shell script in the Bash environment itself. The Ubuntu-based Bash environment comes with both the vi and nano text editors. The vi editor is more powerful, but if you’ve never used it before, you may want to start with nano. It’s easier to use if you’re new.

For example, to create a bash script in nano, you’d run the following command in bash:

This would open the Nano text editor pointed at a file named “myscript.sh” in your user account’s home directory. (The “

” character represents your home directory, so the full path is /home/username/myscript.sh.)

Start your shell script with the line:

Enter the commands you want to run, each one on its own line. The script will run each command in turn. Add a “#” character before a line to treat it as a “comment”, something which helps you and other people understand the script but which isn’t run as a command. For more advanced tricks, consult a more detailed guide to Bash scripts on Linux. The same techniques will work in Bash on Ubuntu on Windows.

Note that there’s no way to run Windows programs from within the Bash environment. You’re restricted to Linux terminal commands and utilities, just as you would be on a typical Linux system.

We’ll use a basic “hello world” script as an example here:

If you’re using the Nano text editor, you can save the file by pressing Ctrl+O and then Enter. Close the editor by pressing Ctrl+X.

How to run windows programs from windows 10’s bash shell

Make the Script Executable and then Run It

You’ll probably want the make the script executable so you can run it more easily. On Linux, that means you need to give the script file the executable permission. To do so, run the following command in the terminal, pointing it at your script:

How to run windows programs from windows 10’s bash shell

To run the script, you can now just run it in the terminal by typing its path. Whenever you want to launch the script in the future, just open the Bash shell and type the path to the script.

(If the script is in the current directory, you can run it with ./myscript.sh)

How to run windows programs from windows 10’s bash shell

How to Work With Windows Files in a Bash Script

To access Windows files in the script, you’ll need to specify their path under /mnt/c, not their Windows path. For example, if you wanted to specify the C:\Users\Bob\Downloads\test.txt file, you’d need to specify the /mnt/c/Users/Bob/Downloads/test.txt path. Consult our guide to file locations in Windows 10’s Bash shell for more details.

How to Incorporate Bash Commands into a Batch or PowerShell Script

Lastly, if you have an existing batch file or PowerShell script you want to incorporate commands into, you can run Bash commands directly using the bash -c command.

For example, to run a Linux command in a Command Prompt or PowerShell window, you can run the following command:

This trick allows you to add Bash commands into batch files or PowerShell scripts. The Bash shell window will appear when a Bash command is running.

Update: If you have multiple Linux environments installed, you can use the wslconfig command to choose the default Linux environment used when you run the bash -c command.

How to run windows programs from windows 10’s bash shell

To create a shortcut to a Bash script from within Windows, just create a shortcut like normal. For the shortcut’s target, use the bash -c command we outlined above and point it at the Bash script you created.

For example, you’d point a shortcut at ” bash -c “

Chris Hoffman is Editor-in-Chief of How-To Geek. He’s written about technology for over a decade and was a PCWorld columnist for two years. Chris has written for The New York Times and Reader’s Digest, been interviewed as a technology expert on TV stations like Miami’s NBC 6, and had his work covered by news outlets like the BBC. Since 2011, Chris has written over 2,000 articles that have been read nearly one billion times—and that’s just here at How-To Geek. Read more.

How to run windows programs from windows 10’s bash shell

In the Creators Update, Windows 10’s Bash shell now allows you to run Windows binaries and standard Command Prompt commands, right from Bash. You can run both Linux and Windows programs from the same Bash shell, or even incorporate Windows commands into a Bash script.

What You Need to Know

Here are some basic details you need to know about this feature:

  • User Account: Programs launched from the Bash shell will run as if they were launched by the current Windows user account.
  • Permissions: These programs will have the same permissions as the Bash.exe process. So, if you want these commands to have Administrator access, you’ll need to run the Bash shell as Administrator.
  • Working Directory: Windows programs share the same “working directory” as the Bash shell. So, if you run a command that lists the contents of the current directory, it will list the contents of the current working directory in the Bash shell. Use the cd command to change working directories.

With that in mind, let’s take a look at how to run a program.

How to Run a Windows Program

To run a Windows program, enter the path to the program’s .exe file in the Bash shell. Remember that your Windows C: drive is available at /mnt/c in Bash. The Bash environment is also case-sensitive, so you have to specify the correct capitalization.

Let’s say you wanted to launch the Ping utility located at C:\Windows\System32\PING.EXE. You’d run the following command:

The following command wouldn’t work, because Bash is case-sensitive:

How to run windows programs from windows 10’s bash shell

This is a bit more complicated if the path contains complex characters like spaces and brackets, like the Program Files folders. You have to “escape” spaces, brackets, and other complex characters by prefixing them with a “\” character.

For example, let’s say you wanted to run the Internet Explorer program located at C:\Program Files (x86)\Internet Explorer\iexplore.exe. You’d have to run the following command in Bash:

Note the “\” before the space and bracket characters. These characters must be “escaped” or Bash won’t realize the characters are part of a file path.

How to run windows programs from windows 10’s bash shell

How to Pass an Argument to a Command

The Bash shell passes arguments directly to the commands you execute.

For example, if you wanted to ping example.com, you’d run:

Or, if you wanted to open the Windows hosts file in Notepad, you’d run:

You use the standard Windows file path when passing a file path directly to a Windows program. That’s because Bash passes the argument directly. Notepad.exe and other Windows programs expect a Windows file path.

How to run windows programs from windows 10’s bash shell

How to Run a Built-in Command

Some Windows commands aren’t .exe files, but are built into the Command Prompt itself. For example, this includes the dir command you might normally run in a Command Prompt. To run such a command, you need to run the cmd.exe binary associated with the Command Prompt and pass it the command as an argument with /C, like so:

For example, to run the dir command built into the Command Prompt, you’d run the following command:

How to run windows programs from windows 10’s bash shell

How to Add Directories to the Path

The Windows Services for Linux environment treats Windows executables similar to the way it treats Linux binaries. This means that you can add a directory containing .exe files to the path and then execute those .exe files directly. For example, to add the System32 directory to your path, you’d run:

You could then run Windows .exe files located in the System32 folder directly, like so:

How to run windows programs from windows 10’s bash shell

How to Pipe the Output of One Command to Another

The output of a Windows command can be piped to a Linux command, and vice versa. For example, you can use the ipconfig.exe -all command to list details about your network interfaces and pipe it to the Linux grep command to search the output. For example, to list all information about your connection and search for sections matching “IPv4 Address”, you’d run:

That’s the basic process. These commands will also work when incorporated into a Bash script, so you can write a Bash script that incorporates both Windows commands and Linux utilities. If it runs in the Bash shell, it will work in a Bash script.

And, if you want to go the other way, you can use the “bash -c” command to run Bash commands from the standard Windows Command Prompt.

Lawrence Abrams
  • August 22, 2020
  • 10:49 AM
  • 0

How to run windows programs from windows 10’s bash shell

The Windows Subsystem for Linux is bridging the divide between Windows and Linux by letting you run Windows 10 programs directly within a Linux shell.

One of the strengths of the Windows Subsystem for Linux (WSL) is that you not only can run a Linux distribution in Windows 10, but you also have the flexibility of running Windows 10 programs in Linux.

This ability allows Linux to control aspects of Windows or for Windows programs to interact with the WSL file system or their output processed by Linux commands.

It also allows WSL users to create complex shell scripts that affect the Linux distribution and can also be used to execute commands in Windows 10.

How to launch a Windows 10 executable from WSL Linux

Both Windows 10 and Linux use a ‘PATH’ variable that contains a list of folders that are searched when you execute a program.

If you try and run a program and it cannot be found in the PATH, both Linux and Windows will tell you that the program cannot be found. In those cases, you would need to launch the program using its complete path like “C:\Notepad2\Notepad.exe.”

When Windows 10 launches a WSL distribution, it will configure the Linux PATH variable to include the standard Linux binary folders and your regular Windows 10 path.

You can view this path by typing the env | grep “PATH” command at a WSL shell prompt.

Note: Your normal Windows drive letters are automatically mounted under ‘/mnt/c’, ‘/mnt/d’, etc.

When you are in a WSL shell, you can execute a Windows 10 program simply by typing its full name, including the .exe extension.

If you do not include the .exe extension when executing a command, WSL will think its a Linux command.

For example, if you want to launch the Windows Notepad to edit a PHP source file, you would enter the command:

This command will allow you to edit the Linux file using Notepad instead of a normal Linux text editor.

If you wanted to launch a program that is not in your PATH, you would need to specify the full filename.

For example, if you wanted to use 7Zip to archive a folder, but it’s not in your path, you would use a command like:

Notice how we had to enclose the 7z.exe command in quotes as “program files” contains a space.

It should be noted that you will not be able to launch Windows 10 programs that require Administrative privileges in WSL. Likewise, if a Linux file requires elevated privileges, you will not be able to access it with a Windows program.

Processing the output of Windows commands

In addition to launching programs to interact with files in WSL, you can also process the output of Windows 10 programs in Linux.

When a Windows console program is executed, its output is displayed directly in Linux rather than Windows.

This output can then be processed using programs such as awk, sed, sort, etc.

As a simple example, if we wanted to get a list of Windows 10 services sorted by the service name, we could use the following command:

This feature also allows you to use Windows applications as part of complex Linux shell scripts.

These shell scripts could be used to check for processes, monitor file changes, execute commands based on the Windows 10 process’s output, and many other tasks.

While you may be able to find Windows equivalents for most Linux programs, by mixing and matching both environments using WSL, you get the best of both worlds.

This feature allows you to use the tools you are most comfortable within either environment.

Along with Windows 10 Anniversary update for summer 2016, came the possibility to run ubuntu binaries inside the new Windows Subsystem for Linux (WSL), a “lightweight” virtualized subsystem.

Unfortunately, launching C:\Windows\System32\bash.exe , another bash ELF binary starts a process inside the WSL, from where you cannot escape! You may launch only other ELF binaries.

So how can I execute *.exe files from Windows Bash?[1]

How to run windows programs from windows 10’s bash shell

5 Answers 5

In the Windows 10 Creators Update (build 1703, April 2017), this is natively supported. So you can now run Windows binaries from Linux.

notepad.exe or any other .exe (the extension is needed and it needs being on your path, some older versions need the whole path)

. and vice versa using one of the following:

  • bash.exe -c command_to_run i.e: bash.exe -c ls
  • bash -c command_to_run i.e: bash -c ls
  • wsl command_to_run i.e: wsl “ls” ; or specify the distro you want to use to run it using:
    • ubuntu run ls

For more information, see the above linked article.

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

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

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.

How to run windows programs from windows 10’s bash shell

Linux’s Bash shell is coming to Windows, courtesy of a collaboration between Microsoft and Ubuntu-creator Canonical. Type bash into Windows 10’s Start menu, and you’ll be able to instantly get a full Linux command-line environment.

Many developers prefer Linux—and even Mac OS X, which also includes the Bash shell—because of its access to a whole universe of utilities that often don’t work on Windows. Adding the Bash shell to Windows is just another way Microsoft is trying to make Windows more attractive to Linux developers. Remember, Microsoft’s Azure cloud hosting service can run Linux servers, too.

It’s not a virtual machine or container

Before this, you could use Bash on Windows, but through heavy virtual machines or by remotely accessing a Bash session running on a remote server somewhere. There’s also Cygwin, a hacky solution featuring a variety of Linux tools recompiled for Windows. Many people assumed Windows 10’s rumored Linux compatibility would be something along these lines. But they were wrong. It’s more awesome.

This solution will be an app available in the Windows Store, and it will provide a full Ubuntu image that runs in userspace as a program on your desktop. Programs compiled for Linux will just run without even needing to be recompiled for Windows. You can use Ubuntu’s apt-get command to download and install programs, and it’ll just work. Developers can write Bash scripts and run them on Windows. It’s reportedly just as fast as running the same utilities natively on Ubuntu Linux.

This is all thanks to a new subsystem quietly placed into Windows 10 build 14251 back in January. The lxcore.sys and lxss.sys files form the new “Windows Subsystem for Linux (WSL).”

Canonical’s Dustin Kirkland is thrilled about the technology, and explains it this way: “A team of sharp developers at Microsoft has been hard at work adapting some Microsoft research technology to basically perform real time translation of Linux syscalls into Windows OS syscalls. Linux geeks can think of it as sort of the inverse of ‘wine’—Ubuntu binaries running natively in Windows.”

Apt-get works just like it does on Ubuntu, with access to the same software packages.

It’s a developer toolset, not a complete Linux system

Microsoft’s solution is surprisingly capable. You get the exact same Linux utilities and they’ll run on your Windows system directly. Although Bash is sandboxed, you can access your file system via the shell and work with the files and folders on your computer. Both your Linux utilities and Windows programs will have access to the same set of files.

But it has some limitations. It will be beta technology when it launches, and not everything will work properly out of the gate.

As Microsoft notes, “This is a developer toolset to help you write and build all your code for all your scenarios and platforms.” It’s not a full Ubuntu virtual machine. You can’t use it to host servers, as you could on Linux. If you need that, you can always install Linux in a virtual machine using Microsoft’s Hyper-V technology, VirtualBox, VMware, or something similar.”

Don’t expect a graphical Linux desktop, either. “We are also only working on command line,” says Microsoft’s Russ Alexander in a video. “This is all about the developer.”

Lastly, these Bash tools won’t be able to interact directly with any Windows tools. You can’t run a Bash command from PowerShell, or a Windows command from within Bash. This means you can’t use Bash scripts to automate Windows commands, unfortunately. Bash command-line tools get access to the same files Windows does, but that’s it!

Bash commands can interact with your normal Windows file system.

Here’s how you can get it

This feature isn’t out yet, but it’s on its way. It will be part of the stable version of Windows when Windows 10’s Anniversary Update is released this summer. Until then, you’ll need to be on the Insider Preview track to get the latest unstable version of Windows 10 “Redstone.”

An Ubuntu 14.04 LTS-based Bash application will shortly be added to the Windows Store, followed by a Ubuntu 16.04 LTS-based application once Ubuntu 16.04 LTS launches on April 21.

Want to learn more? There’s a lot of information out there now. Microsoft’s announcement covers the basics and Microsoft’s Scott Hanselman provides some background. Canonical’s Dustin Kirkland provides an explanation targeted at readers familiar with Linux. You can also watch an informative 30-minute video featuring Hanselman, Kirkland, and others who worked on the project.

After being launched in the Anniversary Update, the Windows Subsystem for Linux was made stable with the release of the Fall Creators Update. Ubuntu and openSUSE are now available for use on Windows, with Fedora and more Linux variants to follow shortly.

What You Need to Know About Windows 10’s Bash Shell

Virtual machines, containers, or Linux software that has been built for Windows are not what you’ll find here (like Cygwin). Instead, Windows 10 provides a Linux-optimized Windows Subsystem that may be used to execute Linux apps. Using Microsoft’s abandoned Project Astoria for running Android applications on Windows, this is a Windows version of Android.

You may think of it as the anti-Wine. The Windows Subsystem for Linux allows you to run Linux software on Windows, whereas Wine allows you to run Windows applications on Linux.

Since Microsoft and Canonical collaborated on this project, a full Ubuntu Bash shell environment is now available on top of this subsystem. This isn’t Linux in any way, shape, or form. Linux is the operating system’s kernel, and it isn’t available at this location. As an alternative, the Bash shell and the identical binaries that you would typically execute on Ubuntu Linux are now available to you. According to free software advocates, most Linux operating systems should be referred to as “GNU/Linux” because they contain a lot of GNU software. In reality, the Bash shell you’ll receive is little more than a collection of GNU utilities and related programmes.

Zsh and other command-line shells can also be used, despite the fact that this functionality was initially dubbed “Bash on Ubuntu on Windows”. Other Linux distributions are now supported as well. In addition to Ubuntu, you can also pick openSUSE Leap or SUSE Enterprise Server.

There are a few restrictions in place. Neither the background server software nor the graphical Linux desktop apps are officially supported by this. The command-line functionality isn’t flawless, thus not every command-line programme works.

How to Install Bash on Windows 10

As the 32-bit version of Windows 10 does not support this function, make sure you’re using the 64-bit version of Windows 10. If you’re still using the 32-bit version of Windows 10, it’s time to upgrade to the 64-bit version.

Turn Windows Features On Or Off in Windows Control Panel if you have a 64-bit version of Windows. “Windows Subsystem for Linux” must be enabled in the list, then the “OK” button must be pressed.

When your computer begs for a restart, select “Restart immediately” from the menu. You can’t use the functionality unless you perform a system restore.

Open the Microsoft Store from the Start menu and type in “Linux” in the search bar when your computer has restarted. The “Linux on Windows?” banner has a “Get the programmes” button.

A list of all Linux distributions currently available in the Windows Store will appear. This includes Ubuntu, openSUSE Leap, and openSUSE Enterprise, with a guarantee that Fedora will arrive shortly.

UPDATE: Despite the fact that Debian and Kali are now accessible in the Store, they are not featured here. If you’re looking for “Debian Linux” or “Kali Linux,” you may locate and install them by searching.

A Linux distribution may be installed in the same way as any other Store programme by clicking it and then clicking the “Get” or “Install” button.

We recommend Ubuntu if you’re unsure which Linux environment to choose. Other Linux systems are now available for customers with more particular demands than only the widely used Ubuntu Linux version.

Install different Linux distributions and each one will have its own unique shortcuts. If you want to run numerous Linux distros at once, you may do so in separate windows.

Windows may load a custom-built Linux-based kernel when you enable WSL. After that, you might install Ubuntu, Debian, or any other Linux Distros (distributions) of your need and choice. The first Windows Subsystem for Linux (WSL) was released by Microsoft 5 years earlier. It has undergone significant changes since: the initial WSL didn’t play a full Linux kernel, didn’t even run in a virtual environment, and didn’t enable GUI apps without additional measures. Bash is included in WSL-based Linux distributions such as Ubuntu. They’re the most convenient approach to installing Bash on a Windows 10 computer.

Bash is included in WSL-based Linux systems such as Ubuntu. The most convenient approach to installing Bash on a Windows 11 computer is there. Windows 10 users can also install WSL. WSL 2 is used in Windows 11, as it is in later versions of Windows 10. The 2nd version has been rewritten to run the entire Linux kernel under a Hyper-V hypervisor for enhanced compliance. Windows 11 gets and downloads a Linux kernel developed by Microsoft Corporation and processes it in the background when you activate the option. The kernel is kept up to date by Windows Update Feature. If you want to have one, you can get your own customized Linux kernel.

Several Linux Operating systems include BASH as their primary terminal. To get Linux running on Windows, you’ll need to download and install WSL. Luckily, the installation procedure has been simplified and can now be completed with just one command in Windows PowerShell. You’ll need a window command-line prompt having Administrator privileges to accomplish this. We’ll be using the Windows Terminal for this purpose, but you may alternatively use Command Prompt. Click the Start button, put “Terminal” further into the search field area, right-click on the Terminal option, and choose “Run as Administrator”. The “Run as Administrator” option provides and grants full command line prompt permissions for resources, programs, and commands.

How to run windows programs from windows 10’s bash shell

In the Windows Terminal (or command prompt), use the wsl —install and press Enter. It will start the download and installation of the assets that are required for Windows Subsystems for Linux (WSL). The subsystem is many 100 megabytes, so this could take a couple of minutes.

How to run windows programs from windows 10’s bash shell

Here is the installation process for WSL.

How to run windows programs from windows 10’s bash shell

As this process downloads the installation materials from the official website, you must have an active internet connection. Your system will also have to be restarted after it is completed. To restart instantly, type shutdown /r /t 0 and press Enter. Once your computer resumes, the installation will autonomously continue. It will start by downloading and installing Ubuntu before requesting you to choose a username and password. They shouldn’t have to be associated with your Windows 11 credentials, and you should not be using the same password twice. Once you’ve chosen your password, Ubuntu will startup.

The UNIX username can also be different from the Windows username. It is utterly up to you whether or not to use a username that is devoid of spaces. The New Password and Re-type new password must be the same and are required. It is illustrated in below screen:

How to run windows programs from windows 10’s bash shell

How To Setup Other Linux Distributions

WSL comes with Ubuntu as the primary Linux operating system, although it isn’t the only one accessible. Type wsl —list —online or wsl -l -o in Terminal after running wsl –install -d OpenSUSE-42. By running wsl —install -d , you can install and configure any of the distributions listed in the below image. You may have a different set of distributions depending on the operating system requirements and updating. If you wish to install Debian, for instance, type wsl —install -d Debian. If you choose, you may get them from the Microsoft Store.

How to run windows programs from windows 10’s bash shell

PowerShell and Command Prompt does not care about the case. The case is important in Linux terminals. You can use this command to install various Windows Linux distributions on your PC by running it many times. That’s all there is to it. Bash is Ubuntu’s default terminal. Bash may be used by running Ubuntu (or any other Linux distribution) from either the Start menu or via the Windows Console.

You can also utilize the preceding technique to install the Windows Subsystem (WSL). We suggest simply executing the statement above because it requires more clicking. To do so, move towards the Start menu and write “Windows features” into the search area. Use the shortcut to the option for Turning Windows Features either On or Off. Click “OK” after enabling the highlighted checkbox. Your computer will be asked to restart.

How to run windows programs from windows 10’s bash shell

Conclusion

We have tried simple ways to discuss the use of bash in Windows 11 using WSL and more methods. We have also discussed the installation of other distributions through WSL on the windows operating system and hope you like it.

About the author

How to run windows programs from windows 10’s bash shell

Omar Farooq

Hello Readers, I am Omar and I have been writing technical articles from last decade. You can check out my writing pieces.

In Windows Operating Systems, some tasks which are critical for the Operating System to run, can be performed only by Administrators. Same rule is applicable for Windows Server 2022 also. A normal Windows user cannot run programs, or run commands from PowerShell, which can cause system wide effects.

Windows User Access Control (UAC) is one of the important security features in Windows, which prevents unauthorized changes to the Operating System, its files or configuration by unauthorized users.

In this example, I want to configure an IPv4 address to Windows Server 2022. Changing IPv4 address by an unauthorized user can cause serious negative implications to the Operating System, or its users. Changing IP address requires administrative level permissions in Windows Server 2022. A normal Windows user cannot perform this task.

To understand the concept of Windows User Access Control (UAC), please refer below images. Below image shows a PowerShell console, which shows current user as “jajish”, who is not an administrator. The command used to find the current logged-in user is “whoami”.

How to run windows programs from windows 10’s bash shell

Now, the user “jajish” (who is not an administrator) is trying to run a PowerShell cmdlet to configure an IPv4 address. The PowerShell cmdlet to configure a new IPv4 address is shown below.

How to run windows programs from windows 10’s bash shell

Following image shows that PowerShell displaying an error, showing that, the operation is not permitted.

How to run windows programs from windows 10’s bash shell

Now, let us try to run PowerShell as local Administrator, and then run the same PowerShell cmdlet.

How to run a program as administrator from Desktop short cut

To run a program as Administrator from Desktop, first create a short cut for the program at Desktop, right-click the short cut, and click “Run as administrator” from the context menu, as shown below.

How to run windows programs from windows 10’s bash shell

Now enter the password of the user “administrator”, when prompted. Click “Yes” button after entering the password.

How to run windows programs from windows 10’s bash shell

A new PowerShell window is opened as user “administrator”. You can again check who is the current user, bye running “whoami” command.

How to run windows programs from windows 10’s bash shell

Now, again run the above permission denied “New-NetIPAddress” cmdlet, which required elevated permission. You can see that the cmdlet executed successfully as user “administrator”.

How to run windows programs from windows 10’s bash shell

How to use Start-Process cmdlet to run a program as administrator

You may also use “Start-Process” PowerShell cmdlet to run a program as administrator. Use below command to run a program as administrator, using “Start-Process” PowerShell cmdlet.

Refer following screenshot to understand the “Start-Process” PowerShell cmdlet more clearly. In this example, I am trying to run command prompt (cmd.exe), which is located in “C:\Windows\System32\” folder as a different user (administrator).

How to run windows programs from windows 10’s bash shell

Now the Windows User Access Control (UAC), will prompt for the user id and password. Enter administrator user id and its password, as shown below. Click “OK” button to run the program as administrator.

How to run windows programs from windows 10’s bash shell

You can see that the command prompt program (cmd.exe) is run as user “administrator”, as shown below.

How to run windows programs from windows 10’s bash shell

How to run a program as administrator from Windows Taskbar Search Box

You may run a program as administrator from Windows Taskbar Search Box. To run a program as administrator from Windows Taskbar Search Box, just search for the program from Search box, then right-click the search result and select “Run as administrator” from the context menu. Please refer below image.

How to run windows programs from windows 10’s bash shell

How to run a program as administrator from Windows Run box

Another way to run a program as administrator is to run it from Windows “Run box”. You can open Windows run box by right-clicking Windows start menu button, and then by clicking “Run” from the context menu. You can also open “Run box” by pressing Windows key + R key together from Windows Desktop.

Once the Windows “Run box” is open, type-in the program to run, and then hit Control + Shift + Enter keys together.

How to run windows programs from windows 10’s bash shell

Windows User Access Control (UAC) will prompt you to enter administrator password. Type-in the administrator password, to run the program as administrator.

How to run windows programs from windows 10’s bash shell

How to run windows programs from windows 10’s bash shell

Windows 10’s Anniversary Update is now stable, and with it comes the Bash shell developers were so excited about when Microsoft announced it. If you’re using an up-to-date Windows 10 system, you can install it today.

How to get it

As long as you’ve updated your Windows 10 PC to the Anniversary Update, and you’re using a 64-bit version of the OS, Bash should work. The feature is compatible with all editions of Windows 10, including Windows 10 Home

Bash isn’t installed by default. You’ll have to activate a few quick options to enable it.

First, open the Settings app and head to Update & security > For developers. Enable Developer mode here.

After you do, open the Control Panel and head to Programs > Turn Windows features on or off. Put a check mark next to Windows Subsystem for Linux (Beta) and click OK to activate the feature.

You may be prompted to reboot. After you’re done, you can just open the Start menu, type bash, and press Enter. A command prompt window will appear. Agree to install Bash and Windows will download the files and install them for you. You’ll also have to provide a username and password that you’ll use in the Bash shell.

Once you’re done, you can now open the Start menu and search for Bash again. You’ll find a “Bash on Ubuntu on Windows” shortcut that launches the shell.

How to run windows programs from windows 10’s bash shell

The Windows Subsystem for Linux feature is still in beta, and not every Linux application you try will work perfectly.

What about Ubuntu 16.04 LTS?

The Ubuntu-based Bash environment is currently still based on the previous long-term service release, Ubuntu 14.04. However, Ubuntu released Ubuntu 16.04 LTS earlier this year.

So when will the newer Ubuntu 16.04 LTS release be available? In a recent comment, Microsoft’s Rich Turner explained: “We have to add some additional capabilities to make it work well, but we are looking at 16.04 support for a future release.”

In the Windows 10 Anniversary update, Microsoft has added a big new feature to its Windows 10 operating system. Microsoft and Canonical collaboration has helped us to get a Windows operating system which is capable of running the Bash shell. It is just a toolset but not a complete Linux system or a virtual machine or Cygwin software. Windows based bash shell is based on one of the Microsoft’s project Astoria which was used for running Android apps on Windows operating system.

This new feature has the same environment as in Linux and can be used to run Linux commands directly on Windows. You can also run bash shell scripts which depend on the Linux command line utilities. All the command line utilities are similar to the native Linux environment. So, you can also access the Windows file system from the bash shell. Since it is still a beta version, you can get all the things to work out well at this stage. There are few limitations out here. The bash shell won’t work with graphic software and servers as well. Also, note that you cannot launch the Bash commands via Windows command line or vice versa. Let’s see how to run the bash shell on Windows 10.

Enable Bash Shell on Windows 10

Sorry Windows 10 32bit users you are out of the league. You need 64 bit Windows 10 operating system to use bash shell. If you are on the 64bit operating system, then follow the below steps to enable the bash shell.

  1. Click on the Start button on the bottom left corner of the screen or press the Windows key to open the Start menu.
  2. Select the Settings option in the Start menu. The settings window will appear on the screen.How to run windows programs from windows 10’s bash shell
  3. Click on the Update & Security icon in the Settings window. Click on For developers in the left side pane and select the Developer mode by clicking on the radio button near to it.
  4. A confirmation window will open on the screen. Click on the Yes button to enable the developer mode.How to run windows programs from windows 10’s bash shell
  5. Now, open Control panel > Programs and Features and click on the Turn Windows features on or off.How to run windows programs from windows 10’s bash shell
  6. Tick the check box to enable the Windows Subsystem for Linux (Beta) option from the list of Window features. and click on OK button.
  7. Click on the Restart now button to restart the PC. Once your PC restarted, click on the Start button, type bash and hit the enter key.

If you are running the bash.exe file for the first time, then you will be prompted to accept the terms of service. Once it is accepted “Bash on Ubuntu on Windows” application will be automatically downloaded.

How to Use Bash Shell on Windows 10

Now you have successfully enabled the bash shell on your Windows 10 PC. As said above this feature has utilities similar to that of Linux environment. So you most of the Linux commands will work here and you can also access all the command in line software. Let’s see how to use the bash shell in Windows 10.

  1. Click on the Start button, type bash and hit the enter key.
  2. By default, you will be given a root shell and will have administrator permissions on the Windows. You can now use the Linux commands and start using the bash shell.
  3. Here are some of the apt-get commands to install and to do some updates to the Ubuntu environment.
    • sudo apt-get update: To downloads the package lists from the repositories and display the updated information.
    • sudo apt-get install packagename: To install an application package.
    • sudo apt-get remove packagename: To uninstall an application package.
    • sudo apt-cache search word: To search for available application packages with given word.
    • sudo apt-get upgrade: To upgrade installed application packages to the latest versions.
  4. Once you have successfully installed an application package, you can launch it by entering the package name and hit the enter key.

If you find this tutorial useful, do share it with your friends. Let us know your suggestions in the below comments section.

Windows 10 has recently added a Bash Shell support. It is not just a simple shell. It contains a complete Linux subsystem, which means you can run Linux native code directly on Windows.

The Ubuntu Sub System (New Bash Shell) in Windows 10 is a truly Linux kernel (unlike cygwin, which is just a shell). It means that you can compile on Windows in the Sub System to Linux COFF binary file which also works if you copy that to the Linux system. It works vice versa.

I am developing some scripts and bots using Python3, and I found it simpler and convenient to use this Ubuntu Sub System on Windows 10. I am a Windows OS user and a casual Linux fan, and this works best for me.

It is more than enough if you want to develop some scripts (Python, BASH etc) for Linux. So you have the best of both worlds, while you still can enjoy Windows for the gaming, legacy software, Windows Batch CMD and if you are a geek, you still can write and run your scripts quickly e.g. awk, sed …

On the New Bash Shell, your windows Disk structure is mounted at /mnt/c, /mnt/d … so yes, it is a real sub-system instead of a emulator.

How to Enable Bash Shell on Windows 10?

Click the start and type in “Turn Windows Features on/off” and hit return. Alternatively, you can go to Control Panel and navigate to Programs, Turn Windows Features On/Off. Both methods should give you this dialog.

How to run windows programs from windows 10’s bash shell

Enable Ubuntu at Windows 10 via Turn Windows Feature On/Off

Scroll down and tick “Turn Linux Subsystem (Beta)”. It takes a few minutes before the Linux shell is made ready. You probably need to restart your PC before changes are taken into effect. On the first time, open the command line shell as administrator and type in lxrun /install to install the ubuntu sub shell (download the binaries/images from the Microsoft Store)

How to run windows programs from windows 10’s bash shell

How to Disable/Remove Bash Shell on Windows 10?

If you decide to remove the Linux Shell on Windows, here is how you should type in the following command in the Windows Cmd Prompt:

How to Change Default User on Bash Shell Windows?

At the very first time after setup, you are prompted a default user and set the password. You could change this later so that every time you open the bash shell, the default user is logged in.

The above command sets root account by default.

How to Install Software on Bash Shell Windows?

The answer is apt-get package manager. Basically the user experience is almost exactly the same as on the true Ubuntu OS. Let’s see below screenshot that I run the sudo apt-get install g++ to install the g++ compiler on the Linux Sub System.

How to run windows programs from windows 10’s bash shell

These commands are also working exactly as expected:

The latest Windows 10 Insider Preview Build 14316 brought in a ton of new features, including Windows Subsystem for Linux. Aimed at developers, the subsystem is added in the latest test iteration of Windows 10 to allow developers to use Linux utilities without using a VM or a remote system. Windows 10 Anniversary Update slated for release this summer, will bring the ability to use Bash to run command-line Linux applications. As Microsoft has offered a preview of several features of the Anniversary Update in the latest Build 14316, running Bash on Windows 10 is also one of them.

You can enroll in Windows Insider Program to take a look at all the new features of Windows 10 14316. Once enrolled, follow this guide to run Ubuntu on Windows 10.

How to run windows programs from windows 10’s bash shell

How to run Ubuntu on Windows 10

In this guide, we will help you run Ubuntu on Windows 10. Once in, you will be running Ubuntu 14.04 “trusty,” and can also install the tools that you need, using the Apt package manager.

  • Visit this page to enroll in Windows Insider Program.
  • Under System Settings, select Advanced Windows Update options.
  • Set your update type to the Fast ring. How to run windows programs from windows 10’s bash shell
  • Go to the Settings app on your PC.
  • Click on Update & Security >For Developers > toggle Developer mode on. How to run windows programs from windows 10’s bash shell
  • Check for new updates and apply them. You are looking for the Insider Preview 14316.
  • Restart your computer.
  • Search for Windows Features >Turn Windows features on or off. How to run windows programs from windows 10’s bash shell
  • Enable Windows Subsystem for Linux (Beta) in the Windows features. How to run windows programs from windows 10’s bash shell
  • Reboot your computer.
  • Search for Bash in the Start menu. Alternatively, open Command Prompt and type bash.
  • This will prompt you to install Ubuntu on Windows 10. Once you accept the terms and conditions, the subsystem is then downloaded for you from the Windows Store. Note that this is 1GB heavy download, so you might want to do it on a faster internet connection.
  • Once it’s downloaded, search for Bash on Ubuntu on Windows from the Start Menu.

You will now be able to use Linux utilities, without having to run a virtual machine or a remote system. Bash on Windows 10 has access to your Windows filesystem, so you will be able to work on the same files from within Bash.

How to run windows programs from windows 10’s bash shell

Remember, this is not technically Linux, as you are running a userspace version of Ubuntu, running on WSL (not Linux kernel). But, you will be able to run Bash shell commands, Bash scripts, and Bash shell tools. Microsoft also says that Ubuntu on Windows 10 allows you to run Linux-first tools like Ruby and Python directly on Windows.

Lawrence Abrams
  • August 29, 2020
  • 10:05 AM
  • 2

How to run windows programs from windows 10’s bash shell

Both the Windows and Linux operating systems include applications that would be useful for either operating system.

Unfortunately, to use Linux programs in Windows, you would typically need to find versions that have been ported to Windows.

Using the Windows Subsystem for Linux (WSL), you can now launch Linux applications directly in a Windows 10 command prompt or PowerShell prompt.

How to run Linux programs in a Windows 10 command prompt

Today, we will show you how to execute Linux applications directly in a command prompt using the wsl.exe console application.

The wsl.exe command is a Windows Subsystem for Linux utility that launches the default installed Linux distribution when executed without any arguments.

This command also has the -e command-line argument that will launch an application from the default WSL Linux distribution directly in a Windows command prompt.

When launching a Linux application in the command prompt, the command will interact with the Windows file system rather than the Linux distribution filesystem.

The Linux application’s output will also be displayed directly in the command prompt so that other Windows programs can use it.

For example, using the command find . -name *.txt will use the default Linux distro’s find command to search the current Windows folder and its subfolders for files ending with the .txt extension.

It will then display any that are found, as shown below.

When executing commands, WSL will use the default installed Linux distribution. To check which distribution is the default one, you can run the wsl -l command.

If you wish to run a command from a different Linux distribution, you would need to use the -d command-line argument.

For example, to run Metasploit from Kali Linux in the Windows 10 command prompt, you would use the wsl -d kali-linux -e msfconsole command.

In addition to running Linux commands in a Windows 10 command prompt, you can use both native Windows programs and WSL Linux programs with each other.

Even better, you can do so from a PowerShell prompt as well.

For example, if you wanted to use PowerShell to list all recently installed updates, but only display the update name and its install date, you can use the following command:

The above command uses the get-hotfix PowerShell command to list all recently installed updates and the Linux awk command to process its output.

As you can see, having the ability to mix and match Windows and Linux applications extends both the Windows 10 command prompt and PowerShell to execute complex and powerful commands.

The only caveat to this interoperability is that you cannot currently launch Linux commands that require elevated Windows privileges.

Linux users celebrated when it was reported that Bash shell was coming to Windows. And while it was not readily available to all users at first, the Windows 10 Creators Update made Linux on Windows more accessible.

Want to join in on the fun? Here’s how you can have Linux on Windows operating system without having to go through a virtual machine.

How to run windows programs from windows 10’s bash shell

Defining Bash

Bash is basically a subsystem for Ubuntu. With Bash, you have a Linux system running inside Windows. It’s the very same Bash you’d find in Linux. You can use it to execute Linux commands without the need for a virtual machine or dual booting.

Using Bash shell, developers can experience Linux natively on a Windows machine.

Enabling Linux on Windows

There are two ways of enabling a Windows subsystem for Linux. One is through PowerShell and the other would be through Windows Features.

Use PowerShell

Search for PowerShell and run it as an administrator. Once open, type this command and press Enter after:

How to run windows programs from windows 10’s bash shell

You will be prompted to confirm by hitting Y or N. Press Y to proceed then reboot your computer. If it’s already installed, you won’t have to restart.

Use Windows Features

Use Search to look for a Control Panel application called Turn Windows Features On or Off.

Note: You can also get to the application by heading directly to Control Panel > Programs > Programs and Features > Turn Windows Features On or Off.

How to run windows programs from windows 10’s bash shell

Once open, go through the list of features until you find Windows Subsystem for Linux. Tick the box to enable the option.

How to run windows programs from windows 10’s bash shell

The computer will run and apply some changes. After it’s done, you will be asked to restart your computer.

Downloading a Linux Distro

Windows should now be able to run Linux. Now you have to download a Linux distro like Ubuntu for Windows to enter Linux commands.

Simply head on over to the Microsoft Store and download the Linux distro of your choice. You need to be logged in to proceed.

There are multiple systems available, but we’ll install Ubuntu and use it throughout the rest of this post. The download will likely take a while because of the large file size.

Running Linux

The Linux system you installed will run like a regular Windows application. Open Ubuntu. It will perform a one-time installation. You will be able to use Ubuntu Linux faster the next time you open the application.

Once installed, you will be asked to enter a username and a password. Provide all the necessary information.

From here on out, you will be able to go through the directory as you would in Linux. You will need to use SUDO APT to run root commands. You can also use APT-GET, APT INSTALL, AND APT UPDATE. You’re pretty much free to do everything you can do in a Linux terminal.

One thing to remember is that the Windows files system will be located inside the MNT folder.

How to run windows programs from windows 10’s bash shell

If you want to edit Windows files from the Linux system, you would have to enter CD MNT, do LS then enter CD C and another LS to locate all the files stored inside Windows. Enjoy Linux with Windows 10!

Christopher Jan Benitez is a freelance writer for hire who provides actionable and useful web content to small businesses and startups. In his spare time, he religiously watches professional wrestling and finds solace in listening to ’80s speed metal. Read Christopher’s Full Bio

If you have to do it more than once, automate it!

You will often find yourself repeating a single task on Linux over and over again. It may be a simple backup of a directory or it could be cleaning up temporary files or it can even be cloning of a database.

Automating a task is one of the many useful scenarios where you can leverage the power of bash scripting.

Let me show you how to create a simple bash shell script, how to run a bash script and what are the things you must know about shell scripting.

Create and run your first shell script

Let’s first create a new directory named scripts that will host all our bash scripts.

Now inside this ‘scripts directory’, create a new file named hello.sh using the cat command:

Insert the following line in it by typing it in the terminal:

Press Ctrl+D to save the text to the file and come out of the cat command.

You can also use a terminal-based text editor like Vim, Emacs or Nano. If you are using a desktop Linux, you may also use a graphical text editor like Gedit to add the text to this file.

So, basically you are using the echo command to print “Hello World”. You can use this command in the terminal directly but in this test, you’ll run this command through a shell script.

Now make the file hello.sh executable by using the chmod command as follows:

And finally, run your first shell script by preceding the hello.sh with your desired shell “bash”:

You’ll see Hello, World! printed on the screen. That was probably the easiest Hello World program you have ever written, right?

Here’s a screenshot of all the steps you saw above:

How to run windows programs from windows 10’s bash shell

Convert your shell script into bash script

Confused? Don’t be confused just yet. I’ll explain things to you.

Bash which is short for “Bourne-Again shell” is just one type of many available shells in Linux.

A shell is a command line interpreter that accepts and runs commands. If you have ever run any Linux command before, then you have used the shell. When you open a terminal in Linux, you are already running the default shell of your system.

Bash is often the default shell in most Linux distributions. This is why bash is often synonymous to shell.

How to run windows programs from windows 10’s bash shell

The shell scripts often have almost the same syntaxes, but they also differ sometimes. For example, array index starts at 1 in Zsh instead of 0 in bash. A script written for Zsh shell won’t work the same in bash if it has arrays.

To avoid unpleasant surprises, you should tell the interpreter that your shell script is written for bash shell. How do you do that? You use shebang!

The SheBang line at the beginning of shell script

The line “#!/bin/bash” is referred to as the shebang line and in some literature, it’s referred to as the hashbang line and that’s because it starts with the two characters hash ‘#’ and bang ‘!’.

When you include the line “#!/bin/bash” at the very top of your script, the system knows that you want to use bash as an interpreter for your script. Thus, you can run the hello.sh script directly now without preceding it with bash.

How to run windows programs from windows 10’s bash shell

How to run windows programs from windows 10’s bash shell

Adding your shell script to the PATH (so that it can be run from any directory)

You may have noticed that I used ./hello.sh to run the script; you will get an error if you omit the leading ./

Bash thought that you were trying to run a command named hello.sh. When you run any command on your terminal; they shell looks for that command in a set of directories that are stored in the PATH variable.

You can use echo to view the contents of that PATH variable:

The colon character (:) separates the path of each of the directories that your shell scans whenever you run a command.

Linux commands like echo, cat etc can be run from anywhere because their executable files are stored in the bin directories. The bin directories are included in the PATH. When you run a command, your system checks the PATH for all the possible places it should look for to find the executable for that command.

If you want to run your bash script from anywhere, as if it were a regular Linux command, add the location of your shell script to the PATH variable.

First, get the location of your script’s directory (assuming you are in the same directory), use the PWD command:

Use the export command to add your scripts directory to the PATH variable.

Notice that I have appended the ‘scripts directory’ to the very end to our PATH variable. So that the custom path is searched after the standard directories.

The moment of truth is here; run hello.sh:

How to run windows programs from windows 10’s bash shell

It works! This takes us to the end of this tutorial. I hope you now have some basic idea about shell scripting. You can download the PDF below and practice what you learned with some sample scripting challenges. Their solutions are also provided in case you need hints.

*Nix Nirvana

icrosoft continues to invest on making Windows 10 the best productivity operating system, and in the Anniversary Update, the company is not only including great improvements and changes, but also adding a big feature for developers. We’re talking about the Linux Bash shell, and this is a big deal.

Bash shell is simply a command-line utility that has been part of Linux for a long time, and it’s often used by developers. Microsoft added it directly into Windows 10 with the Anniversary Update, and everything works thanks to the new Windows Subsystem for Linux.

Bash on Ubuntu on Windows 10 works natively — there is no emulator, virtual machine, or anything of that sort. Microsoft and Canonical (the company behind Ubuntu) collaborated to bring a version of Bash that runs in the new subsystem alongside Windows applications. But don’t get confused, this isn’t Linux on Windows either, it’s just a tool that allows you to run the same commands as if you were using a Linux computer.

Microsoft is focusing the new tool for developers, as such Bash doesn’t come installed by default. In this guide, we’ll walk you through the steps to install the Bash shell command-line tool on your Windows 10 PC.

How to install Bash on Ubuntu on Windows 10

Before trying to install the Bash shell on Windows 10, there are a few prerequisites. First and foremost, you need to be running the Windows 10 Anniversary Update on your machine. If you’re not, you can use our guide to get the update on your device.

The second requirement is to be running the 64-bit version of Windows 10. If you’re running a 32-bit version of the operating system, you can use this guide to move to the 64-bit version.

To install Bash shell on your Windows 10 PC, do the following:

  1. Open Settings.
  2. Click on Update & security.
  3. Click on For Developers.
  4. Under “Use developer features”, select the Developer mode option to setup the environment to install Bash.

On the message box, click Yes to turn on developer mode.

  • After the necessary components install, you’ll need to restart your computer.
  • Once your computer reboots, open Control Panel.
  • Click on Programs.
  • Click on Turn Windows features on or off.

  • Check the Windows Subsystem for Linux (beta) option.
  • Click OK.

  • Once the components installed on your computer, click the Restart now button to complete the task.
  • After your computer restarts, you will notice that Bash will not appear in the “Recently added” list of apps, this is because Bash isn’t actually installed yet. Now that you have setup the necessary components, use the following steps to complete the installation of Bash:

    1. Open Start, do a search for bash.exe, and press Enter.
    2. On the command prompt, type y and press Enter to download and install Bash from the Windows Store.

  • Then you’ll need to create a default UNIX user account. This account doesn’t have to be the same as your Windows account. Enter the username in the required field and press Enter (you can’t use the username “admin”).
  • Close the “bash.exe” command prompt.
  • Now that you completed the installation and setup, you can open the Bash tool from the Start menu like you would with any other app.

    It’s important to note that unlike the real Bash shell you’ll find in Linux, the version of the command line utility has some limitations with Windows.

    For example, the Windows Subsystem for Linux wasn’t designed to run Linux graphical applications (e.g. KDE, Gnome, etc.) on Windows 10. The tool is only to offer developers a text-based command-line feature to run Bash and core Linux tools within the operating system.

    In addition, while Linux applications can access the system files and pretty much everything on your main drive, you can’t launch or use scripts on Windows programs.

    Finally, remember that Microsoft is releasing this feature with the “beta” label on it, which means that it’s still a work in progress, not every intended feature is included, and sometimes it may not work correctly.

    With the Windows 10 Anniversary Update, Microsoft is focusing on core functionalities, including:

    • Bash environment to run tools like awk, sed, and grep.
    • Basic features for languages, such as NodeJS / npm, Python, Perl, Git.
    • Command line editor, including vi, emacs, and ssh.
    • Linux user support.
    • Symlink support.
    • Ability to run apt and apt-get for updates and package testing.
    • Ability to mount local a local hard drive using /mnt

    Hope this information will useful for you !

    Bash has been one of the most well-known feature of Linux distributions, which due to its flexibility as well as ease of usage, made it popular among programmers. The Windows’ operating system’s command line interface, cmd.exe, on the other hand, lacked various capabilities of it’s Linux counterpart.

    Microsoft, therefore, in their Anniversary Update, added several features to the Windows 10 OS, with bash being one of them. To install and use it on Windows 10, one need to perform the following steps :

      Start -> Settings -> Update&Security. Under the ‘Use Developer Features’, select ‘Developer mode’.

    How to run windows programs from windows 10’s bash shell
    Selecting the developer mode will pop the following alert. Click yes, and let the computer restart.

    How to run windows programs from windows 10’s bash shell
    How to run windows programs from windows 10’s bash shell
    Go to Control Panel -> Programs and Features -> Turn Windows Features On and Off. In the window that appears, check the ‘Windows Subsystem for Linux’ option, and click OK.

    How to run windows programs from windows 10’s bash shell
    This will trigger an alert asking for the system to be restarted to complete the installation of the required components. After the restart is complete, go to the command prompt, and type ‘bash’. Follow the instructions that appear to install bash from Windows store. After it is installed, it will be required to create a UNIX username. After completing the installation, exit the prompt.

    To access the shell, simply type ‘bash’ in the Windows command prompt, and everything is good to go.

    How to run windows programs from windows 10’s bash shell

    Note that bash runs natively on Windows 10, which is different from using emulators like ‘cygwin’ for Windows which enabled GNU tools to run on unsupported Windows environment. Also, Linux subsystem for Windows 10 is only available on the 64-bit version of the OS.

    By Alisa | Follow | Last Updated August 04, 2021

    Summary :

    How to run windows programs from windows 10’s bash shell

    You can run a program or an exe file from Command Prompt. Check how to do it in this tutorial. MiniTool software, not only provides many useful computer solutions, but also provides users many useful computer software like data recovery program, disk partition manager, system backup and restore software, video editor, etc.

    If you want to run program from CMD (Command Prompt) on Windows 10, you can check the detailed steps below.

    How to Run a Program from CMD in Windows 10

    You can only run the applications that are installed in Windows-created folders like Explorer in Command Prompt.

    Step 1. Open Command Prompt in Windows 10

    At first, you should open Command Prompt application on your Windows 10 computer. You can press Windows + R, type cmd, and press Enter to open normal Command Prompt or press Ctrl + Shift + Enter to open elevated Command Prompt on Windows 10.

    How to run windows programs from windows 10’s bash shell

    Learn how to open/use the Add or Remove Programs feature to uninstall apps on Windows 10/11. Some other ways to delete apps on Windows 11/10 are also included.

    Step 2. Run Program from CMD on Windows 10

    Next you can type start

    command in Command Prompt window, and press Enter to open the target application in CMD. Replace the “program name” with the exact file’s system name of the program but not its shortcut name. For instance: start explorer.

    How to run windows programs from windows 10’s bash shell

    The file’s system name of some common programs in Windows are as follows:

    • Command Prompt: cmd
    • File Explorer: explorer
    • Task Manager: taskmgr
    • Calculator: calc
    • Notepad: notepad
    • Paint: mspaint
    • Windows Media Player: wmplayer

    How to run windows programs from windows 10’s bash shell

    Detailed guide for how to uninstall a program by using CMD (Command Prompt) or PowerShell utility on Windows 10/11.

    How to Run EXE in CMD on Windows 10

    You can follow the instructions below to run an exe file in Command Prompt.

    Step 1. Access Command Prompt window

    You can follow the same operation above to open Command Prompt in Windows 10.

    Step 2. Navigate to the folder of the target program

    Next you can type cd command in Command Prompt window, and press Enter to navigate to the folder that contains the target exe application. Replace “file path” with the exact file path of the exe file.

    You can find the target program folder and click the address bar at the top of File Explorer window to copy the path of the program folder and paste it after cd command. For example, cd C:\Program Files\Windows Media Player.

    Step 3. Run exe from CMD

    After you are in the target program folder path, then you can type start after the selected file path in CMD, and press Enter to run the exe file in Command Prompt. Replace “filename.exe” with the target program name, e.g. start wmplayer.exe.

    How to run windows programs from windows 10’s bash shell

    Bottom Line

    This post introduces how to run a program or exe file from CMD on Windows 10. Hope it helps.

    If you need a free data recovery software to recover deleted/lost files from Windows 10 computer or other storage devices, you can try MiniTool Power Data Recovery.

    MiniTool Power Data Recovery is a Windows data recovery program that allows you to recover data from PC, external hard drive HDD or SSD, USB drive, SD card, memory card, and more. It is very simple to use and 100% clean.

    How to run windows programs from windows 10’s bash shell

    Check how to download DirectX 12 (Ultimate) for Windows 10 or Windows 11 PC for better gaming experience. Also learn what is DirectX 12 (Ultimate) in this post.

    • Facebook
    • Twitter
    • Linkedin
    • Reddit

    ABOUT THE AUTHOR

    How to run windows programs from windows 10’s bash shell

    Position: Columnist

    Alisa is a professional English editor with 4-year experience. She loves writing and focuses on sharing detailed solutions and thoughts for computer problems, data recovery & backup, digital gadgets, tech news, etc. Through her articles, users can always easily get related problems solved and find what they want. In spare time, she likes basketball, badminton, tennis, cycling, running, and singing. She is very funny and energetic in life, and always brings friends lots of laughs.

    Are you ready for Ubuntu on Windows 10? Microsoft is. Its latest Windows Fast Ring update, 14316, is here and it includes Ubuntu and Bash on Windows 10.

    Yes, that’s Ubuntu with the Bash shell running on Windows 10. Miracles do happen!

    This beta version of Windows 10 is the forerunner of the next major Windows 10 update: Windows 10 Redstone 1 (a k a Anniversary Update). This release, AKA Windows 10 SP1, will be out this summer.

    In the meantime, Ubuntu and the Bash shell, are optional. The only thing “Linux” that’s installed by default is the Windows Subsystem for Linux (WSL).

    To give WSL a try, the first thing you have to do is become a Windows Insider. Then, you need to switch your Windows 10 system to the Fast Ring. You do this by going “System Settings > Advanced Windows Update options” and selecting your Insider Preview update setting to the far right. This sets your Windows 10 update to the the Fast Ring.

    After this check for updates, apply all of them, and restart your PC. This gives you its beta operating system so don’t do this on your production machine. Microsoft makes many updates to its Fast Ring releases and adding WSL, Ubuntu, and Bash are only part of them.

    Then, you must turn on Developer Mode via Settings > Update & security > For developers. Next, search for “Windows Features” and choose “Turn Windows features on or off” and enable Windows Subsystem for Linux (Beta).

    After that, to install Bash, you must open the Windows Command Prompt and type “bash.” You’ll be asked to accept the terms of service and download Ubuntu. The typical Ubuntu download is a bit less than one gigabyte. So, if you have a slow Internet connection, be ready to wait. Once installed, you’ll be running a userspace version of Ubuntu 14.04 on top of WSL.

    Technically, you’re not running Linux. It may look like Linux and squeak like Tux, the Linux penguin; but, it’s not Linux. That’s because the Ubuntu userspace is running not on a Linux kernel, but WSL. WSL provides the API hooks to look like Linux to Ubuntu and Linux applications, but it’s not the same thing.

    That said, for high-level developers it sure looks like Linux. Besides being able to run Bash shell commands, you can run Bash scripts, Bash shell tools such as sed, awk, and grep. You can also run, according to Microsoft, “Linux-first tools like Ruby, Git, Python, etc. directly on Windows. You can also access your Windows filesystem from within Bash allowing you to work on the same set of files using your preferred Windows tools or Linux command-line tools.”

    Dustin Kirkland, a member of Ubuntu Product and Strategy team, has added that you will be able to run pretty much the full gamut of Linux shell tools such as “apt, ssh, rsync, find, grep, awk, sed, sort, xargs, md5sum, gpg, curl, wget, apache, mysql, python, perl, ruby, php, gcc, tar, vim, emacs, diff, patch, and most of the tens of thousands binary packages available in the Ubuntu archives!”

    Besides the Linux shell fundamentals and programming languages, developers should notice that it includes support for server programs such as the Apache webserver and the MySQL database management system. This is a very full Linux development environment that just happens to be running on Windows.

    Will people be running a Linux desktop, such as Unity, Cinnamon, KDE, or Gnome, on this hybrid WIndows Linux software stack as well? That’s not the plan. This stack is meant for developers. But, programmers being programmers, I’m sure we’ll soon see people trying to port all Linux userspace programs, including desktops, to Windows. We live in interesting times!

    Use the Linux command line in Windows

    • Tweet
    • Share
    • Email
    • Tweet
    • Share
    • Email

    If you know how to install bash on Windows 10, you can run the Linux command line from within Windows. That way, you can use Linux commands to navigate the file system, create directories with the mkdir command, move files with the mv command, and edit files using Nano.

    Instructions in this article apply to the 64-bit version of Windows 10.

    How to run windows programs from windows 10’s bash shell

    What You Need to Install Bash on Windows

    To run bash, your computer needs to be running a 64-bit version of Windows with a version number no lower than 14393, so update Windows 10 to the latest version before you begin. In order to run the Linux shell, you need to turn on Windows developer mode and enable the Linux subsystem.

    How to Turn on Windows Developer Mode

    To enable developer functions for Windows:

    Right-click the Start menu and select Settings.

    How to run windows programs from windows 10’s bash shell

    Select Update & Security.

    How to run windows programs from windows 10’s bash shell

    Select For developers on the left side.

    How to run windows programs from windows 10’s bash shell

    Select Developer mode.

    How to run windows programs from windows 10’s bash shell

    Select Yes to confirm, then wait for the developer package to install.

    How to run windows programs from windows 10’s bash shell

    Type Windows Features in the desktop search bar and select Turn Windows Features On Or Off.

    How to run windows programs from windows 10’s bash shell

    Check the box beside Windows Subsystem For Linux and select OK.

    How to run windows programs from windows 10’s bash shell

    Select Restart now in the dialog box to reboot your computer to apply the changes.

    How to run windows programs from windows 10’s bash shell

    How to Use Bash in Windows

    After your computer reboots, you’re ready to set up bash for Windows:

    Go to the Microsoft Store and select the Linux distribution of your choice. Install it then launch it.

    Wait for the distribution to finish installing, then create a username in the command window and press Enter. During the first-run process, you’ll have to engage in some basic configuration, depending on the distribution. Often, you must specify a username and password.

    After the installation is successful, close the window and right-click the Start menu, then select Windows PowerShell (Admin).

    How to run windows programs from windows 10’s bash shell

    You may be prompted to enter your Windows administrator password.

    Type bash in the terminal window and press Enter.

    How to run windows programs from windows 10’s bash shell

    You now have a core version of Ubuntu installed on your system without any graphical desktops or subsystem. Therefore, you can now use Linux commands to communicate with the Windows file structure. Anytime you want to run the Linux command line, open the PowerShell or the command prompt and enter bash.

    Copy to Clipboard

    The Command Prompt is a tool that lets users do a variety of tasks from a central location. IT professionals often find this application helpful when completing assignments or projects. It can even be beneficial for average computer users to learn how to use Command Prompt in case they need to troubleshoot. In this article, we discuss what Command Prompt is, the benefits of using this application, how to run a program on Command Prompt and tips to help you use the application.

    What is Command Prompt?

    Command Prompt is an application on most Windows computers that directly communicates with the operating system to automate tasks through scripts and batch files. This application is a text-based command-line interpreter that can work like a navigation tool. It’s also used to complete advanced administration activities or troubleshoot certain issues in Windows. For example, you can use Command Prompt to see everyone who has used your WiFi connection, trace a possible hacker or possibly fix a file that doesn’t open. Using Command Prompt can also give you more control over your computer, including communicating with some programs that communicate exclusively through Command Prompt.

    Benefits of running a program on Command Prompt

    Some benefits of using Command Prompt to run programs and complete tasks include saving time and allowing you to fix issues during a system or GUI (Graphical User Interface) application crash. Sometimes using Command Prompt is a much quicker way to access information or tasks. Running a program on Command Prompt also usually requires less memory space than GUI because the program doesn’t have to process graphical components, so it also takes less time to run the program. If you have a slow processor, Command Prompt can still work efficiently.

    How to run a program on Command Prompt

    Here is a list of steps to help you run a program on Command Prompt:

    1. Open your Start menu and type “cmd” in the search box

    Locate your Start menu in the bottom left corner of your screen and click on it. In the white search box next to the Windows icon, type “cmd.” Command Prompt is the first search result.

    2. Click on Command Prompt to open the application and type your first command

    Right-click on the application and select “Run as administrator,” then a new Command Prompt window opens. This opens a black screen with plain text.

    3. Determine which program you want to run

    Find the folder with the file you want to run. It’s important to mention that Command Prompt can only run programs that are installed in Windows-created folders. You can add a program’s folder to the Command Prompt list to run that program within the application.

    3. Find the file path of the folder with your exe program

    Type “cd [ filepath ] ” into Command Prompt. This allows you to find the folder that contains the .exe program you want to run. In a File Explorer window, you can open the specific folder and copy the file path located in the address bar at the top of the window by pressing C and Ctrl. For example, you can run Google Chrome by locating a folder titled Google Chrome in your Program Files. The file path for that file is “C: \ Program Files \ Google.”

    4. Replace ” [ filepath ] ” in the Command Prompt window with the file path you’ve copied

    Replacing this file path allows you to run both commands and the desired program. You can then press the Enter key on your keyboard. This takes you to the selected file path in Command Prompt.

    5. Type “start [ filename.exe ] ” into Command Prompt, replacing “filename” with the name of your selected file

    Replace ” [ filename.exe ] ” with your program’s name. This allows you to run your program from the file path. For example, you can run Google Chrome by typing “Start Chrome.exe.” You can then hit “Enter” on your keyboard, and the program starts running.

    Tips for using Command Prompt

    Here are a few tips to help you use Command Prompt:

    Make sure you’re running Command Prompt as an administrator. This is an important step when using the application because many commands can only be executed by an administrator profile on your computer.

    Easily open Command Prompt by running Windows Run by holding the Windows button and hitting the R button on your keyboard. You can then type “cmd” and press enter, opening Command Prompt.

    If you’re unsure of what commands to use, you can type “Help” into Command Prompt. This makes a list appear with different common commands you can use.

    Get more information about a command by typing “/?” at the end. This gives you additional information about changing how that command works.

    Keep your computer clean and issue-free by running “sfc/ scannow” in the Command Prompt window. This System File Checker tool can help you identify and fix issues by scanning all your protected files. It also repairs broken files to improve performance on your computer.

    Drag and drop folders into Command Prompt to insert a folder’s location. You can make identifying a file path easier by dragging a folder into the Command Prompt window.

    Use the Function keys (F1-9) as shortcuts. These buttons at the top of your keyboard can help you reenter commands without having to type them again.

    Common commands to use in Command Prompt

    Here is a list of some commands you can use to interact with Command Prompt:

    systeminfo: This displays specific properties and configurations for your computer.

    tasklist: This displays all active tasks and services.

    taskkill: This stops a process or application.

    time: This sets the computer’s time.

    type: This displays all the contents within a text file.

    ver: This shows the Windows version on your computer.

    verify: This tells Windows whether your files are written correctly to a disk.

    xcopy: This copies files and directory trees.

    Please note that none of the companies mentioned in this article are affiliated with Indeed.

    If anything seems off, please contact Zhian Kamvar [email protected]

    The Unix shell has been around longer than most of its users have been alive. It has survived because it’s a powerful tool that allows users to perform complex and powerful tasks, often with just a few keystrokes or lines of code. It helps users automate repetitive tasks and easily combine smaller tasks into larger, more powerful workflows.

    Use of the shell is fundamental to a wide range of advanced computing tasks, including high-performance computing. These lessons will introduce you to this powerful tool.

    Prerequisites

    This lesson guides you through the basics of file systems and the shell. If you have stored files on a computer at all and recognize the word “file” and either “directory” or “folder” (two common words for the same thing), you’re ready for this lesson.

    If you’re already comfortable manipulating files and directories, searching for files with grep and find , and writing simple loops and scripts, you probably want to explore the next lesson: shell-extras.

    Download files

    You need to download some files to follow this lesson.

    1. Download shell-lesson-data.zip and move the file to your Desktop.
    2. Unzip/extract the file. Let your instructor know if you need help with this step. You should end up with a new folder called shell-lesson-data on your Desktop.

    Install software

    If you do not already have the shell software installed, you will need to [download and install][install_shell] it.

    Open a new shell

    After installing the software 3. Open a terminal. If you’re not sure how to open a terminal on your operating system, see the instructions below. 4. In the terminal type cd then press the Return key. This step will make sure you start with your home folder as your working directory.

    In the lesson, you will find out how to access the data files in this folder.

    Where to type commands: How to open a new shell

    The shell is a program that enables us to send commands to the computer and receive output. It is also referred to as the terminal or command line.

    Some computers include a default Unix Shell program. The steps below describe some methods for identifying and opening a Unix Shell program if you already have one installed. There are also options for identifying and downloading a Unix Shell program, a Linux/UNIX emulator, or a program to access a Unix Shell on a server.

    If none of the options below address your circumstances, try an online search for: Unix shell \[your computer model\] \[your operating system\] .

    • Windows
    • macOS
    • Linux

    Computers with Windows operating systems do not automatically have a Unix Shell program installed. In this lesson, we encourage you to use an emulator included in \[Git for Windows\] \[install\_shell\] , which gives you access to both Bash shell commands and Git.

    Once installed, you can open a terminal by running the program Git Bash from the Windows start menu.

    For advanced users:

    As an alternative to Git for Windows you may wish to Install the Windows Subsystem for Linux which gives access to a Bash shell command-line tool in Windows 10.

    Please note that commands in the Windows Subsystem for Linux (WSL) may differ slightly from those shown in the lesson or presented in the workshop.

    For a Mac computer running macOS Mojave or earlier releases, the default Unix Shell is Bash. For a Mac computer running macOS Catalina or later releases, the default Unix Shell is Zsh. Your default shell is available via the Terminal program within your Utilities folder.

    To open Terminal, try one or both of the following:

    • In Finder, select the Go menu, then select Utilities. Locate Terminal in the Utilities folder and open it.
    • Use the Mac ‘Spotlight’ computer search function. Search for: Terminal and press Return .

    To check if your machine is set up to use something other than Bash, type echo $SHELL in your terminal window.

    If your machine is set up to use something other than Bash, you can run it by opening a terminal and typing bash .

    The default Unix Shell for Linux operating systems is usually Bash. On most versions of Linux, it is accessible by running the \[Gnome Terminal\] \[gnome-terminal\] or \[KDE Konsole\] \[kde-konsole\] or \[xterm\] \[xterm\] , which can be found via the applications menu or the search bar. If your machine is set up to use something other than Bash, you can run it by opening a terminal and typing bash .

    This lesson is subject to the Code of Conduct

    Shell Scripts or .SH files are like batch files of Windows which can be executed in Linux or Unix. It is possible to run .sh or Shell Script file in Windows 10 using Windows Subsystem for Linux. In this post, we will show you how to run a Shell Script file in Windows 11/10.

    How to run .sh or Shell Script file in Windows 11/10

    Bash is a Unix shell and command language which can run Shell Script files. You do not need to install Ubuntu or any other Linux Distros unless your scripts need the support of the real Linux kernel. We will share both the methods.

    1. Execute Shell Script file using WSL
    2. Execute Shell Script using Ubuntu on Windows 10

    1] Execute Shell Script file using WSL

    Install WSL or Windows Subsystem for Linux

    Go to Settings > Update & Security > For Developers. Check the Developer Mode radio button. And search for “Windows Features”, choose “Turn Windows features on or off”.

    Scroll to find WSL, check the box, and then install it. Once done, one has to reboot to finish installing the requested changes. Press Restart now. BASH will be available in the Command Prompt and PowerShell.

    Execute Shell Script Files

    1. Open Command Prompt and navigate to the folder where the script file is available.
    2. Type Bash script-filename.sh and hit the enter key.
    3. It will execute the script, and depending on the file, you should see an output.

    On a Linux platform, you usually use SH, but here you need to use BASH. That said, BASH in Windows has its limitations, so if you want to execute in a Linux environment, you need to install Ubuntu or anything similar.

    2] Execute Shell Script using Ubuntu on Windows 10

    Make sure you have Ubuntu or any other Linux distros installed. Ubuntu will mount or make all your Windows directories available under /mnt. So the C drive is available at /mnt/C. So if the desktop will be available at /mnt/c/users/ /desktop.

    Now follow these steps

    1. Type Bash in run prompt, and it will launch the distro prompt.
    2. Navigate to the folder using “cd” command to the folder where the scripts are available.
    3. Type “sh script.sh” and hit enter.

    It will execute the script, and if they have a dependency on any of core Linux features.

    Since Linux is now available in Windows, you need not use any third party applications like Cygwin. WSL should be enough for most of the scenarios to help you run a shell script in Windows 10.

    Date: July 15, 2021 Tags: WSL

    Related Posts

    WSL process exited with code 4294967295 in Windows 11

    Fix Server execution failed error in WSL

    An error occurred mounting one of your file systems WSL error

    [email protected]

    Ashish is a veteran Windows, and Xbox user who excels in writing tips, tricks, and features on it to improve your day to day experience with your devices.

    Primary Sidebar

    report this ad

    By Ariel | Follow | Last Updated December 05, 2019

    Summary :

    How to run windows programs from windows 10’s bash shell

    The PowerShell script is a collection of commands that can be used to change system settings and do other tasks. However, many users don’t know how to run PowerShell script on Windows 10. Don’t worry! MiniTool will walk you through a full guide to do that.

    Quick Navigation :

    • How to Create PowerShell Script on Windows 10
    • How to Run PowerShell Script on Windows 10
    • User Comments

    Windows PowerShell is a command-line shell that enables you to run commands in the scripting environment. If you want to run a PowerShell script, you need to create a script file first. PowerShell script is saved in a text file by using the .ps1 extension.

    However, you may receive the error message “cannot be loaded because running script is disabled on this system” when double-clicking the .ps1 file. To run PowerShell script successfully, you can keep reading the following context.

    How to Create PowerShell Script on Windows 10

    First of all, you need to create PowerShell scripts files. It can be created by using the Notepad. Alternatively, you can use ISE (Integrated Scripting Environment) that is a built-in tool in the preinstalled environment. Here’s how:

    Method 1. Create a PowerShell Script File with Notepad

    Step 1. Type notepad in the search box and click the Notepad on the top result.

    How to run windows programs from windows 10’s bash shell

    Step 2. Now you can write a new script on the context file. For example, copy and paste Write-Host “Congratulations! Your first script executed successfully” into the context file.

    How to run windows programs from windows 10’s bash shell

    Step 3. Then click on the File menu on the upper left corner and click the Save as button.

    How to run windows programs from windows 10’s bash shell

    Step 4. Select a location where t you want to save the file and type a new name for the script file followed by the end of .ps1 such as first_script.ps1. After that, click on the Save button.

    How to run windows programs from windows 10’s bash shell

    Method 2. Create a PowerShell Script File with Integrated Scripting Environment

    In addition, you can use the Windows built-in tool ISE to create a script file. This method is relatively complex, please read the following part carefully.

    Step 1. Type Windows PowerShell ISE in the search box, and then right-click the top result and select Run as administrator option.

    How to run windows programs from windows 10’s bash shell

    Step 2. Press Ctrl + N keys on the keyboard to create a new empty .ps1 file.

    Step 3. In the new empty file, type or paste a new script file that you want to run. For example, we write Write-Host “Congratulations! Your first script executed successfully”.

    How to run windows programs from windows 10’s bash shell

    Step 4. Press Ctrl + S keys on the keyboard to save the script file.

    Step 5. In the file explorer, select a location that you want to save in and rename it followed by the end of .ps1. After that, click on the Save button.

    After you create the script file using Notepad or PowerShell ISE, it should be ready to run. However, it will fail to work by default, because the default PowerShell settings will always prevent any script from executing.

    How to run windows programs from windows 10’s bash shell

    Product key is important to activate your Windows. A great many users are looking for a way to find Windows 10 product key. This post can help you.

    How to Run PowerShell Script on Windows 10

    Now, you may wonder how to run a PowerShell script on Windows 10. To run PowerShell scripts on Windows 10, you need to change the execution policy. Here’s how to do that:

    Step 1. Type PowerShell in the search box, and then right-click the top result and select Run as administrator option.

    How to run windows programs from windows 10’s bash shell

    Step 2. Type the Set-ExecutionPolicy RemoteSigned command in the window and press Enter.

    Step 3. Type A and hit Enter.

    How to run windows programs from windows 10’s bash shell

    Step 4. Then type & “C:\PATH\TO\SCRIPT\first_script.ps1 command and hit Enter to run the PowerShell scripts.

    After you complete all the above steps, you should run PowerShell scripts smoothly and see the outputs.

    ABOUT THE AUTHOR

    How to run windows programs from windows 10’s bash shell

    Position: Columnist

    Ariel is an enthusiastic IT columnist focusing on partition management, data recovery, and Windows issues. She has helped users fix various problems like PS4 corrupted disk, unexpected store exception error, the green screen of death error, etc. If you are searching for methods to optimize your storage device and restore lost data from different storage devices, then Ariel can provide reliable solutions for these issues.

    Back in the Anniversary update, Microsoft introduced a new beta feature called Bash on Ubuntu on Windows. With the Fall Creators update (v1709), the new module is now a stable feature and has a proper name called Linux Subsystem for Windows. With this module, you can use bash shell directly in Windows 10.

    Of course, with the Linux Subsystem for Windows, you can run various Linux distros like Ubuntu, OpenSUSE, Kali, etc., by installing them directly from the Microsoft Store. Follow these steps to install Linux subsystem in Windows 10.

    What is Linux Subsystem for Windows

    If you are an avid Linux user then you may know of Wine, a famous software that lets you run various Windows applications in Linux systems like Ubuntu. Linux Subsystem for Windows is very similar but allows you to run Linux directly in Windows.

    No, Linux Subsystem for Windows is not a virtual machine or a re-complied software like Cygwin. By installing Linux subsystem in Windows 10, you’ll be directly accessing the Linux terminal, run various commands, and install various Linux applications.

    As good as it is, there are some limitations. i.e, you cannot install GUI (at least officially) for your Linux OS and the Linux Subsystem does not support a few terminal commands. Moreover, you may not be able to install or use certain commands and GUI applications due to inherent limitations of the Subsystem. However, for the most part, Linux Subsystem for Windows is pretty robust and gets the job done for a majority of users.

    Verify Your Windows 10 Version

    One thing to keep in mind is that you should be running 64-bit Windows 10 operating system with Fall Creators Update (v1709) or above to use Linux Subsystem for Windows. If you are unsure, check Windows 10 version and proceed to the next steps.

    Control Panel Options to Install Linux Subsystem

    You can easily install Linux subsystem in Windows 10 by enabling a simple feature.

    1. First, open the start menu and search for “Turn Windows features on or off” open it. This is where you can enable extra features in Windows 10.

    2. In the Windows Features window, scroll all the way down, find Windows Subsystem for Linux and select the checkbox next to it. Click on the Ok button to save changes.

    How to run windows programs from windows 10’s bash shell

    3. As soon as you click on the ok button, Windows downloads any necessary files and installs Linux subsystem.

    How to run windows programs from windows 10’s bash shell

    4. Once done, click on the Restart now button to reboot Windows.

    How to run windows programs from windows 10’s bash shell

    After rebooting Windows, you can use the Microsoft store to find the Linux OS of your choice and install it.

    How to run windows programs from windows 10’s bash shell

    How to run windows programs from windows 10’s bash shell

    PowerShell Command to Install Linux Subsystem in Windows 10

    Before you proceed to install Linux Subsystem in Windows 10, save all your work. Your system will restart in the process.

    To install any Linux operating system like Ubuntu, you first need to enable Linux Subsystem for Windows. You can do that using PowerShell.

    1. Search for “PowerShell” in the start menu, right-click on it and select “Run as Administrator.”

    2. In the PowerShell, execute the below command. It will enable the Linux Subsystem feature.

    3. As soon as you execute the command, Windows will download any additional files it requires. Once downloaded, it prompts for your confirmation. Type Y and press Enter.

    4. Now, Windows will enable the additional feature and immediately restarts your system.

    5. You can now install Linux OS. Just open Microsoft Store, search for Ubuntu and click on the “Get” button. This action will download and install Ubuntu.

    Apart from Ubuntu, as of writing this, Microsoft Store has other Linux operating systems like OpenSUSE, SUSE Enterprise Linux, Debian GNU/Linux, and Kali. You can install any of them by simply searching for them and clicking on the “Get” or “Install” button.

    How to run windows programs from windows 10’s bash shell

    6. Once installed, launch Ubuntu by clicking on the “Launch” button or by searching for it in the Start Menu.

    How to run windows programs from windows 10’s bash shell

    That’s all there is to do. It is that simple to install Linux Subsystem in Windows 10. Comment below sharing your thoughts and experiences about using the Linux Subsystem for Windows.