Make a shortcut to Ubuntu bash.exe on Windows 10 that doesn't auto-close

2

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?

Koam

Posted 2017-04-01T15:11:39.280

Reputation: 21

Answers

1

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!

Nicola

Posted 2017-04-01T15:11:39.280

Reputation: 11

0

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

boot13

Posted 2017-04-01T15:11:39.280

Reputation: 5 551

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 – 2017-04-01T16:40:55.107

0

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 

phuclv

Posted 2017-04-01T15:11:39.280

Reputation: 14 930