BAT file to open CMD in current directory

前端 未结 17 1821
清酒与你
清酒与你 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:15

    You could add a context menu entry through the registry:

    1. Navigate in your Registry to HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell and create a key called "Command Prompt" without the quotes.

    2. Set the default string to whatever text you want to appear in the right-click menu.

    3. Create a new key within your newly created command prompt named "command," and set the default string to

      cmd.exe /k pushd %1
      

    You may need to add %SystemRoot%\system32\ before the cmd.exe if the executable can't be found.

    1. The changes should take place immediately. Right click a folder and your new menu item should appear.

    Also see http://www.petri.co.il/add_command_prompt_here_shortcut_to_windows_explorer.htm

    0 讨论(0)
  • 2020-12-22 18:18

    Inside given folder click on the top Affffdress Bar and type cmd and click enter It will open command prompt with current folder address.

    0 讨论(0)
  • 2020-12-22 18:20

    There's more simple way

    start /d "folder path"
    
    0 讨论(0)
  • 2020-12-22 18:21

    you can try:

    shift + right click

    then, click on Open command prompt here

    0 讨论(0)
  • 2020-12-22 18:25

    Referring to answer of @Chris,

    We can also go to parent directory of batch file and run commands using following

    cd /d %~dp0..
    <OTHER_BATCH_COMMANDS>
    cmd.exe
    

    To understand working of command cd /d %~dp0.. please refer below link

    What does it mean by command cd /d %~dp0 in Windows

    0 讨论(0)
  • 2020-12-22 18:27

    You can simply create a bat file in any convenient place and drop any file from the desired directory onto it. Haha. Code for this:

    cmd
    
    0 讨论(0)
提交回复
热议问题