opening CMD with commands already executed












1















Ok so I've started Java at school and we have to compile and run our code through the CMD (no admin privileges)(on windows 10). Every time I open CMD, I have to change the directory to the bin folder to be able to do my Java stuff. My question is: Is there any way to open the CMD so that there have already been specific commands run? i.e. when I open CMD or whatever file I create, can the directory already be set to where I want it to be (as well as a different font colour and title for the CMD window), then I can start using CMD as normal? I haven't really found any comprehensible answers anywhere.










share|improve this question


















  • 1





    For the font color, you can set that using the Application menu of the command prompt. (The icon at the upper left.) Select it, then select Defaults. Then the Colors tab, the Screen Text, then pick your color. Future command prompts will use that color.

    – Doug Deden
    Feb 12 at 0:15






  • 1





    Try this sort of solution for part of your question: superuser.com/questions/1312668/…

    – Pimp Juice IT
    Feb 12 at 0:17











  • And the answers to this question will help with the "can the directory already be set to where I want it to be" part. stackoverflow.com/questions/60904/…

    – Doug Deden
    Feb 12 at 0:18











  • Sure, the link I provided gives you a method to do with a simple shortcut and is easily changeable with no third party tool and no registry edits.... Just plug in the value of the path you want it to open in the Start in: field.

    – Pimp Juice IT
    Feb 12 at 0:21
















1















Ok so I've started Java at school and we have to compile and run our code through the CMD (no admin privileges)(on windows 10). Every time I open CMD, I have to change the directory to the bin folder to be able to do my Java stuff. My question is: Is there any way to open the CMD so that there have already been specific commands run? i.e. when I open CMD or whatever file I create, can the directory already be set to where I want it to be (as well as a different font colour and title for the CMD window), then I can start using CMD as normal? I haven't really found any comprehensible answers anywhere.










share|improve this question


















  • 1





    For the font color, you can set that using the Application menu of the command prompt. (The icon at the upper left.) Select it, then select Defaults. Then the Colors tab, the Screen Text, then pick your color. Future command prompts will use that color.

    – Doug Deden
    Feb 12 at 0:15






  • 1





    Try this sort of solution for part of your question: superuser.com/questions/1312668/…

    – Pimp Juice IT
    Feb 12 at 0:17











  • And the answers to this question will help with the "can the directory already be set to where I want it to be" part. stackoverflow.com/questions/60904/…

    – Doug Deden
    Feb 12 at 0:18











  • Sure, the link I provided gives you a method to do with a simple shortcut and is easily changeable with no third party tool and no registry edits.... Just plug in the value of the path you want it to open in the Start in: field.

    – Pimp Juice IT
    Feb 12 at 0:21














1












1








1








Ok so I've started Java at school and we have to compile and run our code through the CMD (no admin privileges)(on windows 10). Every time I open CMD, I have to change the directory to the bin folder to be able to do my Java stuff. My question is: Is there any way to open the CMD so that there have already been specific commands run? i.e. when I open CMD or whatever file I create, can the directory already be set to where I want it to be (as well as a different font colour and title for the CMD window), then I can start using CMD as normal? I haven't really found any comprehensible answers anywhere.










share|improve this question














Ok so I've started Java at school and we have to compile and run our code through the CMD (no admin privileges)(on windows 10). Every time I open CMD, I have to change the directory to the bin folder to be able to do my Java stuff. My question is: Is there any way to open the CMD so that there have already been specific commands run? i.e. when I open CMD or whatever file I create, can the directory already be set to where I want it to be (as well as a different font colour and title for the CMD window), then I can start using CMD as normal? I haven't really found any comprehensible answers anywhere.







command-line cmd.exe






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 11 at 23:20









SqepiaSqepia

276




276








  • 1





    For the font color, you can set that using the Application menu of the command prompt. (The icon at the upper left.) Select it, then select Defaults. Then the Colors tab, the Screen Text, then pick your color. Future command prompts will use that color.

    – Doug Deden
    Feb 12 at 0:15






  • 1





    Try this sort of solution for part of your question: superuser.com/questions/1312668/…

    – Pimp Juice IT
    Feb 12 at 0:17











  • And the answers to this question will help with the "can the directory already be set to where I want it to be" part. stackoverflow.com/questions/60904/…

    – Doug Deden
    Feb 12 at 0:18











  • Sure, the link I provided gives you a method to do with a simple shortcut and is easily changeable with no third party tool and no registry edits.... Just plug in the value of the path you want it to open in the Start in: field.

    – Pimp Juice IT
    Feb 12 at 0:21














  • 1





    For the font color, you can set that using the Application menu of the command prompt. (The icon at the upper left.) Select it, then select Defaults. Then the Colors tab, the Screen Text, then pick your color. Future command prompts will use that color.

    – Doug Deden
    Feb 12 at 0:15






  • 1





    Try this sort of solution for part of your question: superuser.com/questions/1312668/…

    – Pimp Juice IT
    Feb 12 at 0:17











  • And the answers to this question will help with the "can the directory already be set to where I want it to be" part. stackoverflow.com/questions/60904/…

    – Doug Deden
    Feb 12 at 0:18











  • Sure, the link I provided gives you a method to do with a simple shortcut and is easily changeable with no third party tool and no registry edits.... Just plug in the value of the path you want it to open in the Start in: field.

    – Pimp Juice IT
    Feb 12 at 0:21








1




1





For the font color, you can set that using the Application menu of the command prompt. (The icon at the upper left.) Select it, then select Defaults. Then the Colors tab, the Screen Text, then pick your color. Future command prompts will use that color.

– Doug Deden
Feb 12 at 0:15





For the font color, you can set that using the Application menu of the command prompt. (The icon at the upper left.) Select it, then select Defaults. Then the Colors tab, the Screen Text, then pick your color. Future command prompts will use that color.

– Doug Deden
Feb 12 at 0:15




1




1





Try this sort of solution for part of your question: superuser.com/questions/1312668/…

– Pimp Juice IT
Feb 12 at 0:17





Try this sort of solution for part of your question: superuser.com/questions/1312668/…

– Pimp Juice IT
Feb 12 at 0:17













And the answers to this question will help with the "can the directory already be set to where I want it to be" part. stackoverflow.com/questions/60904/…

– Doug Deden
Feb 12 at 0:18





And the answers to this question will help with the "can the directory already be set to where I want it to be" part. stackoverflow.com/questions/60904/…

– Doug Deden
Feb 12 at 0:18













Sure, the link I provided gives you a method to do with a simple shortcut and is easily changeable with no third party tool and no registry edits.... Just plug in the value of the path you want it to open in the Start in: field.

– Pimp Juice IT
Feb 12 at 0:21





Sure, the link I provided gives you a method to do with a simple shortcut and is easily changeable with no third party tool and no registry edits.... Just plug in the value of the path you want it to open in the Start in: field.

– Pimp Juice IT
Feb 12 at 0:21










1 Answer
1






active

oldest

votes


















2














If you want to run some commands whenever you open any Command Prompt window, you can create a HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRun string variable in the Windows registry and set it to the path of a .cmd/.bat script. That script then can executes whatever commands you want. From cmd /?:




If /D was NOT specified on the command line, then when CMD.EXE starts,
it looks for the following REG_SZ/REG_EXPAND_SZ registry variables,
and if either or both are present, they are executed first.



HKEY_LOCAL_MACHINESoftwareMicrosoftCommand ProcessorAutoRun


and/or



HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRun



Be forewarned: I do not actually recommend setting the AutoRun variable since it affects all cmd.exe instances and could have unexpected (and possibly confusing) side effects that will be hard to debug later if you forget that AutoRun is set in the registry.





Alternatively, if you wish to be able to double-click on an icon, execute some commands, and get an interactive Command Prompt window, then you instead can create a .cmd (or .bat) script:



@echo off
cd SOME_DIRECTORY
SOME_COMMAND
SOME_OTHER_COMMAND

cmd /k


Double-clicking on that script will execute the specified commands, invoke a cmd.exe subshell, and leave it running waiting for additional input.






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%2f1404628%2fopening-cmd-with-commands-already-executed%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    If you want to run some commands whenever you open any Command Prompt window, you can create a HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRun string variable in the Windows registry and set it to the path of a .cmd/.bat script. That script then can executes whatever commands you want. From cmd /?:




    If /D was NOT specified on the command line, then when CMD.EXE starts,
    it looks for the following REG_SZ/REG_EXPAND_SZ registry variables,
    and if either or both are present, they are executed first.



    HKEY_LOCAL_MACHINESoftwareMicrosoftCommand ProcessorAutoRun


    and/or



    HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRun



    Be forewarned: I do not actually recommend setting the AutoRun variable since it affects all cmd.exe instances and could have unexpected (and possibly confusing) side effects that will be hard to debug later if you forget that AutoRun is set in the registry.





    Alternatively, if you wish to be able to double-click on an icon, execute some commands, and get an interactive Command Prompt window, then you instead can create a .cmd (or .bat) script:



    @echo off
    cd SOME_DIRECTORY
    SOME_COMMAND
    SOME_OTHER_COMMAND

    cmd /k


    Double-clicking on that script will execute the specified commands, invoke a cmd.exe subshell, and leave it running waiting for additional input.






    share|improve this answer






























      2














      If you want to run some commands whenever you open any Command Prompt window, you can create a HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRun string variable in the Windows registry and set it to the path of a .cmd/.bat script. That script then can executes whatever commands you want. From cmd /?:




      If /D was NOT specified on the command line, then when CMD.EXE starts,
      it looks for the following REG_SZ/REG_EXPAND_SZ registry variables,
      and if either or both are present, they are executed first.



      HKEY_LOCAL_MACHINESoftwareMicrosoftCommand ProcessorAutoRun


      and/or



      HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRun



      Be forewarned: I do not actually recommend setting the AutoRun variable since it affects all cmd.exe instances and could have unexpected (and possibly confusing) side effects that will be hard to debug later if you forget that AutoRun is set in the registry.





      Alternatively, if you wish to be able to double-click on an icon, execute some commands, and get an interactive Command Prompt window, then you instead can create a .cmd (or .bat) script:



      @echo off
      cd SOME_DIRECTORY
      SOME_COMMAND
      SOME_OTHER_COMMAND

      cmd /k


      Double-clicking on that script will execute the specified commands, invoke a cmd.exe subshell, and leave it running waiting for additional input.






      share|improve this answer




























        2












        2








        2







        If you want to run some commands whenever you open any Command Prompt window, you can create a HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRun string variable in the Windows registry and set it to the path of a .cmd/.bat script. That script then can executes whatever commands you want. From cmd /?:




        If /D was NOT specified on the command line, then when CMD.EXE starts,
        it looks for the following REG_SZ/REG_EXPAND_SZ registry variables,
        and if either or both are present, they are executed first.



        HKEY_LOCAL_MACHINESoftwareMicrosoftCommand ProcessorAutoRun


        and/or



        HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRun



        Be forewarned: I do not actually recommend setting the AutoRun variable since it affects all cmd.exe instances and could have unexpected (and possibly confusing) side effects that will be hard to debug later if you forget that AutoRun is set in the registry.





        Alternatively, if you wish to be able to double-click on an icon, execute some commands, and get an interactive Command Prompt window, then you instead can create a .cmd (or .bat) script:



        @echo off
        cd SOME_DIRECTORY
        SOME_COMMAND
        SOME_OTHER_COMMAND

        cmd /k


        Double-clicking on that script will execute the specified commands, invoke a cmd.exe subshell, and leave it running waiting for additional input.






        share|improve this answer















        If you want to run some commands whenever you open any Command Prompt window, you can create a HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRun string variable in the Windows registry and set it to the path of a .cmd/.bat script. That script then can executes whatever commands you want. From cmd /?:




        If /D was NOT specified on the command line, then when CMD.EXE starts,
        it looks for the following REG_SZ/REG_EXPAND_SZ registry variables,
        and if either or both are present, they are executed first.



        HKEY_LOCAL_MACHINESoftwareMicrosoftCommand ProcessorAutoRun


        and/or



        HKEY_CURRENT_USERSoftwareMicrosoftCommand ProcessorAutoRun



        Be forewarned: I do not actually recommend setting the AutoRun variable since it affects all cmd.exe instances and could have unexpected (and possibly confusing) side effects that will be hard to debug later if you forget that AutoRun is set in the registry.





        Alternatively, if you wish to be able to double-click on an icon, execute some commands, and get an interactive Command Prompt window, then you instead can create a .cmd (or .bat) script:



        @echo off
        cd SOME_DIRECTORY
        SOME_COMMAND
        SOME_OTHER_COMMAND

        cmd /k


        Double-clicking on that script will execute the specified commands, invoke a cmd.exe subshell, and leave it running waiting for additional input.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 15 at 16:46

























        answered Feb 15 at 16:36









        jamesdlinjamesdlin

        1,6701120




        1,6701120






























            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%2f1404628%2fopening-cmd-with-commands-already-executed%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

            How to make a Squid Proxy server?

            第一次世界大戦

            Touch on Surface Book