BAT file to open CMD in current directory

前端 未结 17 1951
清酒与你
清酒与你 2020-12-22 18:09

I have many scripts which I interact with from the command line. Everytime I need to use them, I have to open a command line window and copy+paste and CD to the path to the

17条回答
  •  感情败类
    2020-12-22 18:42

    A bit late to the game but if I'm understanding your needs correctly this will help people with the same issue.

    Two solutions with the same first step: First navigate to the location you keep your scripts in and copy the filepath to that directory.

    First Solution:

    • Click "Start"
    • Right-click "Computer" (or "My Computer)
    • Click "Properties"
    • On the left, click "Advanced System Settings"
    • Click "Environment Variables"
    • In the "System Variables" Box, scroll down and select "PATH"
    • Click "Edit"
    • In the "Variable Value" field, scroll all the way to the right
    • If there isn't a semi-colon (;) there yet, add it.
    • Paste in the filepath you copied earlier.
    • End with a semi-colon.
    • Click "OK"
    • Click "OK" again
    • Click "OK" one last time

    You can now use any of your scripts as if you were already that folder.

    Second Solution: (can easily be paired with the first for extra usefulness)

    On your desktop create a batch file with the following content.

    @echo off
    cmd /k cd "C:\your\file\path"
    

    This will open a command window like what you tried to do.


    For tons of info on windows commands check here: http://ss64.com/nt/

提交回复
热议问题