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:WindowsSystem32bash.exe (Ubuntu on Windows 10), runs a command and doesn't close the terminal.



I made a shortcut with target to C:WindowsSystem32bash.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?










share|improve this question





























    2















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



    I made a shortcut with target to C:WindowsSystem32bash.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?










    share|improve this question



























      2












      2








      2








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



      I made a shortcut with target to C:WindowsSystem32bash.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?










      share|improve this question
















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



      I made a shortcut with target to C:WindowsSystem32bash.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?







      windows-10 shortcuts windows-subsystem-for-linux file-shortcut






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 7 at 2:56









      phuclv

      9,09463890




      9,09463890










      asked Apr 1 '17 at 15:11









      KoamKoam

      113




      113






















          2 Answers
          2






          active

          oldest

          votes


















          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.






          share|improve this answer
























          • Thank you, C:WindowsSystem32bash.exe -c free & pause didn't work. But C:WindowsSystem32bash.exe -c free & bash worked! And with C:WindowsSystem32bash.exe -c free & read it also works but I can't type further commands.

            – Koam
            Apr 1 '17 at 16:40





















          0














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



          C:WindowsSystem32bash.exe -c "free; bash"


          or maybe better



          C:WindowsSystem32bash.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:WindowsSystem32bash.exe --rcfile rc_file 





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1194581%2fmake-a-shortcut-to-ubuntu-bash-exe-on-windows-10-that-doesnt-auto-close%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            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.






            share|improve this answer
























            • Thank you, C:WindowsSystem32bash.exe -c free & pause didn't work. But C:WindowsSystem32bash.exe -c free & bash worked! And with C:WindowsSystem32bash.exe -c free & read it also works but I can't type further commands.

              – Koam
              Apr 1 '17 at 16:40


















            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.






            share|improve this answer
























            • Thank you, C:WindowsSystem32bash.exe -c free & pause didn't work. But C:WindowsSystem32bash.exe -c free & bash worked! And with C:WindowsSystem32bash.exe -c free & read it also works but I can't type further commands.

              – Koam
              Apr 1 '17 at 16:40
















            0












            0








            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.






            share|improve this answer













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







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 1 '17 at 16:37









            boot13boot13

            5,19131940




            5,19131940













            • Thank you, C:WindowsSystem32bash.exe -c free & pause didn't work. But C:WindowsSystem32bash.exe -c free & bash worked! And with C:WindowsSystem32bash.exe -c free & read it also works but I can't type further commands.

              – Koam
              Apr 1 '17 at 16:40





















            • Thank you, C:WindowsSystem32bash.exe -c free & pause didn't work. But C:WindowsSystem32bash.exe -c free & bash worked! And with C:WindowsSystem32bash.exe -c free & read it also works but I can't type further commands.

              – Koam
              Apr 1 '17 at 16:40



















            Thank you, C:WindowsSystem32bash.exe -c free & pause didn't work. But C:WindowsSystem32bash.exe -c free & bash worked! And with C:WindowsSystem32bash.exe -c free & read it also works but I can't type further commands.

            – Koam
            Apr 1 '17 at 16:40







            Thank you, C:WindowsSystem32bash.exe -c free & pause didn't work. But C:WindowsSystem32bash.exe -c free & bash worked! And with C:WindowsSystem32bash.exe -c free & read it also works but I can't type further commands.

            – Koam
            Apr 1 '17 at 16:40















            0














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



            C:WindowsSystem32bash.exe -c "free; bash"


            or maybe better



            C:WindowsSystem32bash.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:WindowsSystem32bash.exe --rcfile rc_file 





            share|improve this answer




























              0














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



              C:WindowsSystem32bash.exe -c "free; bash"


              or maybe better



              C:WindowsSystem32bash.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:WindowsSystem32bash.exe --rcfile rc_file 





              share|improve this answer


























                0












                0








                0







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



                C:WindowsSystem32bash.exe -c "free; bash"


                or maybe better



                C:WindowsSystem32bash.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:WindowsSystem32bash.exe --rcfile rc_file 





                share|improve this answer













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



                C:WindowsSystem32bash.exe -c "free; bash"


                or maybe better



                C:WindowsSystem32bash.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:WindowsSystem32bash.exe --rcfile rc_file 






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 6 at 14:27









                phuclvphuclv

                9,09463890




                9,09463890






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1194581%2fmake-a-shortcut-to-ubuntu-bash-exe-on-windows-10-that-doesnt-auto-close%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Plaza Victoria

                    Puebla de Zaragoza

                    Musa