I would like to make a shortcut on Windows 10 that opens C:\Windows\System32\bash.exe (Ubuntu on Windows 10), runs a command and doesn't close the terminal.

I made a shortcut with target to C:\Windows\System32\bash.exe -c free and it runs the "free" command but closes the terminal right after running it. How to prevent it from closing?

Also what would be better: is there a way to load a bash script using such a shortcut (a set of commands located in a text file that such a shortcut would open and execute one after another) without closing the terminal after the execution? I suppose preventing the terminal from closing when running a "target" and a text file would be two separate methods?

3 Answers 3


You can create a shortcut from the Application folder:

  1. Access the Application folder by entering explorer shell:AppsFolder in Windows Command Prompt.
  2. Right-click on Ubuntu or other applications -> Create shortcut
  3. Click Yes on the msgbox saying the shortcut can be placed on the desktop.
  4. Enjoy!
  • That "shell:AppsFolder" thing is great. I've often banged my head in frustration with Windows "special" shortcut types, like the Ubuntu one is a "CanonicalGroupLimited.Ubuntu2.0.0.4onWindows_"!! Really MS?!?!
    – Jester
    Jul 19, 2020 at 13:07

Adding & pause to the command line might work. I can't test it since I can't run the Linux tools for Windows 10.

  • Thank you, C:\Windows\System32\bash.exe -c free & pause didn't work. But C:\Windows\System32\bash.exe -c free & bash worked! And with C:\Windows\System32\bash.exe -c free & read it also works but I can't type further commands.
    – Koam
    Apr 1, 2017 at 16:40
  • bash -c free & pause won't work because pause is only run after bash has exited. & in Windows is not for running a command in background. bash -c "free & pause" doesn't work either because pause is not a bash command
    – phuclv
    Mar 22, 2020 at 2:13

In this case since you didn't modify any environmental state, you can simply start another bash session like this

C:\Windows\System32\bash.exe -c "free; bash"

or maybe better

C:\Windows\System32\bash.exe -c "free; exec $SHELL"

If environment variables need to be changed then just write the commands in the rc_file and call bash with

C:\Windows\System32\bash.exe --rcfile rc_file 

You must log in to answer this question.

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