• Login
Community
  • Login

How to launch notepad++ synchronously

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
synchronouslyhow to launch
12 Posts 5 Posters 6.0k 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.
  • S
    Stefano Fratoni
    last edited by Feb 9, 2018, 4:05 PM

    this does not work:

    1. start /wait notepad++
    2. call notepad++

    anyone can help me?

    C 1 Reply Last reply Feb 9, 2018, 8:49 PM Reply Quote 0
    • C
      Claudia Frank @Stefano Fratoni
      last edited by Feb 9, 2018, 8:49 PM

      @Stefano-Fratoni

      I ASSUME you are talking about batch processing, correct?
      If so , just put in the complete full path to npp.exe or change dir first.
      No start /wait or CALL needed, afaik.

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 0
      • S
        Stefano Fratoni
        last edited by Feb 12, 2018, 8:14 AM

        @Claudia-Frank said:

        Cheers

        yes i’m talking about batch.
        Using the full path i have the same problem.

        C S 2 Replies Last reply Feb 12, 2018, 12:53 PM Reply Quote 0
        • C
          Claudia Frank @Stefano Fratoni
          last edited by Feb 12, 2018, 12:53 PM

          @Stefano-Fratoni

          hmmm, sorry - it used to work with windows 7. I did this to save the current config files.

          Which OS and npp version are you using?

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 0
          • S
            Scott Sumner @Stefano Fratoni
            last edited by Scott Sumner Feb 12, 2018, 1:28 PM Feb 12, 2018, 1:27 PM

            @Stefano-Fratoni

            I run Notepad++ successfully from a batch file every time I start it up. As @Claudia-Frank partially asks, please supply the data you see when you run ? (menu) -> Debug Info…

            Also, showing the batch file you are trying to make work, and in general providing more detail about what exactly you are doing, what happens when you do it, and what you expect would also be a good idea.

            1 Reply Last reply Reply Quote 1
            • S
              Stefano Fratoni
              last edited by Stefano Fratoni Feb 12, 2018, 2:33 PM Feb 12, 2018, 2:33 PM

              i’m using windows 10
              I’m trying to make a copy of the file I’m opening with notepad++ and once I close the notepad the file I created must be deleted.
              it is basically what makes gvim

              I’m doing this because I need to create the file swap or lock the file.

              this is file batch:
              copy %1 .%1.swp
              start /wait np++ %1
              del .%1.swp

              this is debug info:

              Notepad++ v7.5.1 (32-bit)
              Build time : Aug 29 2017 - 02:35:41
              Path : C:\Users\Stefano\Documents\dati_in_backup\Notepad++\np++.exe
              Admin mode : OFF
              Local Conf mode : ON
              OS : Windows 10 (64-bit)
              Plugins : mimeTools.dll NppConverter.dll NppExec.dll NppExport.dll XMLTools.dll

              1 Reply Last reply Reply Quote 1
              • P
                PeterJones
                last edited by Feb 12, 2018, 3:12 PM

                First thing I see: do you really have an executable np++, because in every version of Notepad++ i’ve seen, it’s notepad++.exe. And if you really have that, is it in your PATH? Because, if not, start /wait isn’t going to be able to see it.

                Looking at the start examples at https://ss64.com/nt/start.html , I was able to craft

                copy %1 .%1.swp
                start /wait "" "C:\Program Files (x86)\Notepad++\notepad++.EXE" "%1"
                del .%1.swp
                
                • because the path to my notepad++ executable has a space, it needs quotes around it. And always quote the "%1", because likely you’ll use this batch file sometime on a file that has a space in it.
                • The first "" is the “TITLE” option; if I tried without that, it would read the first quoted argument (path to executable) as the TITLE, rather than the executable, and wouldn’t do what I wanted.

                But this batch file did for me what you implied you wanted… it created the swap file, ran notepad++ and waited until you exit notepad++ before continuing, then deleted the swap file.

                1 Reply Last reply Reply Quote 0
                • S
                  Stefano Fratoni
                  last edited by Stefano Fratoni Feb 12, 2018, 3:39 PM Feb 12, 2018, 3:38 PM

                  now I’ve tried this way

                  copy %1 .%1.swp
                  start /wait “” “C:\Users\Stefano\Documents\dati_in_backup\Notepad++\notepad++.exe” “%1”
                  del .%1.swp

                  but it doesn’t work. the result is that it opens notepad++ but does not wait for closure

                  my exe is named this way because I simply renamed it myself, but even bringing it back with the original name does not work.

                  I had already seen the link you posted to me , in fact if you check in the paragraph of start / wait says that with winword.exe does not work.

                  1 Reply Last reply Reply Quote 0
                  • G
                    guy038
                    last edited by guy038 Feb 12, 2018, 4:51 PM Feb 12, 2018, 4:47 PM

                    Hello @stefano-fratoni and All,

                    When you copy / paste text, in normal video, from our site, beware about single and double quotes ! Indeed, NodeBB site changes, for instance :

                    • The string 'Text' into the string ‘Text’

                    • The string "Text" into the string “Text”

                    So, all your text must be normalized with, either, the apostrophe ( \x{0027} ) or quotation mark (\x{0022} ) character, before being executed !


                    @Peterjones,

                    I currently have my “working” N++ in the folder C:\_751 of my Win XP configuration. So, after starting a CMD console windows and moving to the right folder :

                    d:\Documents and Settings\xvr823.380490A\Mes documents (17:04:33)
                    
                    >cd /d C:\_751
                    
                    C:\_751 (17:04:42)
                    

                    The command below works fine :

                    >start "" /wait "notepad++.exe"
                    
                    C:\_751 (17:05:19)
                    

                    This one, without the title, and the /WAIT parameter, was OK, too !

                    >start notepad++.exe change.log
                    
                    C:\_751 (17:05:34)
                    

                    Even, this simple DOS line, did launch N++ and get the change.log file :

                    >notepad++ change.log
                    
                    C:\_751 (17:05:52)
                    

                    => No problem at all, with my out of date XP machine :-))

                    Cheers,

                    guy038

                    1 Reply Last reply Reply Quote 1
                    • P
                      PeterJones
                      last edited by Feb 12, 2018, 7:16 PM

                      @guy038, two questions: what happens if you’re not in the same directory as notepad++.exe ? (Oh, I just removed it from my path, and found that start /wait notepad++.exe was still able to find it. That surprises me. Maybe it’s because my global PATH still includes my NPP directory, or because the install registered the location of notepad++.exe with windows somewhere; interesting.)

                      Second, what happens if you try to specify the full path to notepad++ executable, when running from some different directory?

                      cd \
                      start /wait notepad++.exe
                      echo first
                      start /wait "c:\_751\notepad++.exe"
                      echo second
                      start /wait "" "c:\_751\notepad++.exe"
                      echo second
                      

                      @Stefano-Fratoni , ss64 says it doesn’t work for winword. But notepad++.exe is not winword. When I have tried it for notepad++.exe (multiple times today, before each of my posts), it consistently works: it runs notepad++, but doesn’t return to the next command line until I exit Notepad++.
                      What happens if you run a cmd.exe window, and just manually type in

                      start /wait "" notepad++.exe
                      

                      Does it immediately return you to the command line: ie, if you Alt+TAB from NPP window back to cmd.exe window, is it still waiting for the command to finish or not? Because for me, when I run that, cmd.exe doesn’t give me the next prompt until after I’ve closed.

                      For example, comparing these two commands:

                      (start notepad++.exe) && echo done
                      (start /wait notepad++.exe) && echo done
                      

                      The first immediately prints “done” in the cmd.exe window, while NPP is loading in the background. The second, on the other hand, waits until after I’ve exited NPP before it prints “done” in the cmd.exe window.

                      Also, when you are running your batch file (assuming your batch file uses real quotes, not smart quotes like your post uses), were you running from a cmd.exe window, or from the Win+R run-prompt, or from a windows shortcut? It might be that there’s a difference.

                      For me, from cmd.exe window or from Win+R does the same. For example, if I save the following as %TEMP%\nppsync.bat

                      start /wait "" notepad++
                      echo done
                      pause
                      

                      Interesting: If I run Win+R then type %TEMP%\nppsync.bat, it opens npp, but if I tab into the cmd.exe window, it hasn’t said done or given the pause message yet – and won’t, until I close the notepad++ window. If I run a cmd.exe window, and cd %TEMP%, then run nppsync.bat, it gives the same behavior. But if I run cmd.exe window, cd \, and run %TEMP%\nppsync.bat, it will immediately continue thru to pause, even before Notepad++ is finished loading in the background. But if I do cmd.exe, then cd \ and call %TEMP%\nppsync.bat, then it will go back to the desired wait-for-NPP behavior.

                      Could you try those exact experiments, and let us know how they differ from my results? (And, FYI, yes, if you edit the nppsync.bat file in Notepad++, and do the Save As, you can type the filename exactly like %TEMP%\nppsync.bat and it will save it in your TEMP directory.) And if you get the same results I did, then please explain exactly how you are running your original batch file, and copy/paste the entire batch file here, indented 4 spaces, or surrounded like the following trick:

                      ```z
                      contents here
                      ```
                      

                      so it will render like

                      contents here
                      

                      in the forum

                      1 Reply Last reply Reply Quote 1
                      • G
                        guy038
                        last edited by guy038 Feb 12, 2018, 11:02 PM Feb 12, 2018, 11:00 PM

                        Hi, @peterjones,

                        As you said, I created a batch file, in the usual My Documents folder, named test.bat, with contents, below :

                        @echo off
                        
                        cd \
                        
                        start /wait notepad++.exe
                        echo first
                        pause
                        
                        start /wait "c:\_751\notepad++.exe"
                        echo second
                        pause
                        
                        start /wait "" "c:\_751\notepad++.exe"
                        echo third
                        

                        After opening a new DOS console, and starting the Test.bat batch file

                        d:\Documents and Settings\xvr823.380490A\Mes documents (22:52:45)
                        
                        >test.bat
                        

                        Of course, I, immediately, got a Win WP windows, with the message ( after translation ! ) :

                        Windows does not find 'n/wait'. Check if you correctly entered the name and retry. For searching a file, click on the Start button, then on Search.

                        After clicking on the ‘OK’ button, in the DOS console, it displays :

                        The system cannot find the notepad++.exe file.
                        first
                        Press a key to continue...
                        

                        Now, pressing any key, a new DOS console opened, with title C:\_751\notepad++.exe and the text :

                        Microsoft Windows XP [version 5.1.2600]
                        (C) Copyright 1985-2001 Microsoft Corp.
                        
                        D:\ (22:57:20)
                        
                        >
                        

                        On closing this new DOS console windows, the message ^CEnd the commands program (Y/N) ? was displayed on the first DOS console

                        Then, after hitting the N key, it displays :

                        second
                        Press a key to continue...
                        

                        Now, hitting any key, again, this time, notepad++ started, with focus on the last current file, before closing N++ ;-))

                        Finally, on closing Notepad++, it displays, on the DOS console :

                        third
                        
                        D:\ (23:02:51)
                        

                        So, seemingly, Peter, that is exactly what you expected to !

                        Cheers,

                        guy038

                        1 Reply Last reply Reply Quote 2
                        • S
                          Stefano Fratoni
                          last edited by Feb 13, 2018, 1:43 PM

                          this works.
                          thank of all for the support!!

                          COPY %1 .%1.swp
                          START /wait "" NOTEPAD++ -multiInst "%1"
                          DEL .%1.swp
                          
                          1 Reply Last reply Reply Quote 1
                          8 out of 12
                          • First post
                            8/12
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors