Community
    • Login

    Execute bat-file from Notepad++

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • AntonA
      Anton
      last edited by

      Is there any easy and convenient way to run currently opened bat-file from Notepad++?
      For example, with a hotkey or a menu or addon?

      PeterJonesP mkupperM 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Anton
        last edited by

        @Anton ,

        The File > Open in Default Viewer will run the current file based on its windows filetype assocation, which would run the batch. So Settings > Shortcut Mapper could assign a keystroke to that menu entry, if you wanted.

        Or Run > Run…, $(FULL_CURRENT_PATH) – which you can Save to a named run-command, and give it a keyboard shortcut

        1 Reply Last reply Reply Quote 3
        • mkupperM
          mkupper @Anton
          last edited by

          @Anton said in Execute bat-file from Notepad++:

          Is there any easy and convenient way to run currently opened bat-file from Notepad++?
          For example, with a hotkey or a menu or addon?

          Keep in mind that batch files are normally run from a command prompt window. My normal practice has been to edit the batch file in Notepad++ and to then Alt+Tab to a command prompt window to test the batch file. Windows does not offer a direct mechanism for an application such as Notepad++ to tell a process such as cmd.exe to execute a batch file. That’s why you need to switch using Alt+Tab as Microsoft wants the user to be in control.

          However, you can “run” a batch file from Notepad++ by telling it to open a new command prompt window and that command prompt runs your batch file. There are two ways to do this:

          Add a file://c:/bin/batch_file.bat link. When you double-click the link it’ll open a command prompt window that’s running your batch file. When the batch file exits the command prompt window goes away. Thus you likely will want to add a PAUSE command or some other mechanism for suspending the batch file so you can view the results.

          Another way is to take advantage of the Run / Run command and to point that at your batch file. Unfortunately, there does not see to be a way to add custom entries to the Run menu so that you can set up a Notepad++ keyboard shortcut that runs a a batch file. As with the file:// links you will end up with a new command prompt window that then vanishes at the end of execution. You can add /K to the string to
          run cmd.exe to keep it open when the batch file terminates though then would then need to manually close those windows.

          1 Reply Last reply Reply Quote 4
          • AntonA
            Anton
            last edited by

            Thank you!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors