Loading ...
Sorry, an error occurred while loading the content.

Running commands in CMD box

Expand Messages
  • John Shotsky
    I would like to execute a command from NoteTab which is intended to operate from within a cmd box. When I do it manually, the command works, so I know the
    Message 1 of 6 , Jan 17, 2012
    • 0 Attachment
      I would like to execute a command from NoteTab which is intended to operate from within a cmd box. When I do it
      manually, the command works, so I know the command is structured correctly. However, I can't figure out a way to execute
      the same command from within NoteTab. I see the cmd window flash by, but the command is not executed. What I need to do
      is SUBMIT a command to the cmd box, but I'm not sure how to set that up from within Notetab. I've written a dos .bat
      file that does the same thing: when I run it from a cmd box, it works, but if I try to execute it from Win 7, it
      doesn't. I've tried both ^!DOS and &!Shell, but neither works as needed.

      I wrote a dir.bat command to execute from Win7, and that appears to work. Of course, it uses a built in command rather
      than an external command. It appears to me that the path for the external command is flashed by when the dos window goes
      by, but that's about one second, and I can't read the rest of it. When I type 'java' from within the cmd box, I get the
      help information, so I know the path is set right.

      For what it's worth, this is the command that works when executed from within the cmd window AND when executed through
      the .bat file within the cmd window, but not when executed using a .bat file in win7 or from within NoteTab.
      java -jar d:\cb2cb\McxExtract.jar -i d:\WorkImage\CL1986.mcx

      Any ideas?
      Thanks,
      John



      [Non-text portions of this message have been removed]
    • Axel Berger
      ... I place most of my commands inside batch files (.bat), so I have more than one line, and end all of them with a command to read any logs or error
      Message 2 of 6 , Jan 17, 2012
      • 0 Attachment
        John Shotsky wrote:
        > It appears to me that the path for the external command is flashed
        > by when the dos window goes by, but that's about one second,

        I place most of my commands inside batch files (.bat), so I have more
        than one line, and end all of them with a <pause> command to read any
        logs or error messages. Of course a batch will also allow you to insert
        all kinds of <echo> commands to check for things.

        One problem I have come across is paths. In the registry there is an
        entry block "App Paths" like this:
        ------------------------------------
        [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App
        Paths\Firefox.exe]
        @="F:\\Winprog\\Mozilla_Firefox\\Firefox.exe"
        "Path"="F:\\Winprog\\Mozilla_Firefox"
        ------------------------------------

        So on just typing "firefox mypage.htm" in "Run", Windows will know where
        to find the program. Using "^!Shell firefox.exe mypage.htm" this
        information seems not to be avalilable and I have to prepend the program
        with its full path. The same is true when calling programs from a batch
        (I learnt the hard way). This doesn't make it easier running the same
        batch on different machines, unless you're extremely disciplined in
        installing all programs in exactly the same way, as I keep being
        reminded every second day.

        Of course your using the newest and brightest with more bells and
        whistles than I'll ever be able to understand may well have introduced
        all kinds of new complications.

        Axel

        --
        Dipl.-Ing. F. Axel Berger Tel: +49/ 2174/ 7439 07
        Johann-Häck-Str. 14 Fax: +49/ 2174/ 7439 68
        D-51519 Odenthal-Heide eMail: Axel-Berger@...
        Deutschland (Germany) http://berger-odenthal.de
      • John Shotsky
        Thanks, Axel, that is worth a try. I generally save paths and file names to variables, so if I can just deduce the path to java on *any* machine, I should be
        Message 3 of 6 , Jan 17, 2012
        • 0 Attachment
          Thanks, Axel, that is worth a try. I generally save paths and file names to variables, so if I can just deduce the path
          to java on *any* machine, I should be good. I'll try it manually in a batch file first. So, if anyone knows how to
          'find' the path to java (32-bit only), using NoteTab, I'll try that too.

          Regards,
          John
          RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

          From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
          Sent: Tuesday, January 17, 2012 16:08
          To: ntb-clips@yahoogroups.com
          Subject: Re: [Clip] Running commands in CMD box


          John Shotsky wrote:
          > It appears to me that the path for the external command is flashed
          > by when the dos window goes by, but that's about one second,

          I place most of my commands inside batch files (.bat), so I have more
          than one line, and end all of them with a <pause> command to read any
          logs or error messages. Of course a batch will also allow you to insert
          all kinds of <echo> commands to check for things.

          One problem I have come across is paths. In the registry there is an
          entry block "App Paths" like this:
          ------------------------------------
          [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App
          Paths\Firefox.exe]
          @="F:\\Winprog\\Mozilla_Firefox\\Firefox.exe"
          "Path"="F:\\Winprog\\Mozilla_Firefox"
          ------------------------------------

          So on just typing "firefox mypage.htm" in "Run", Windows will know where
          to find the program. Using "^!Shell firefox.exe mypage.htm" this
          information seems not to be avalilable and I have to prepend the program
          with its full path. The same is true when calling programs from a batch
          (I learnt the hard way). This doesn't make it easier running the same
          batch on different machines, unless you're extremely disciplined in
          installing all programs in exactly the same way, as I keep being
          reminded every second day.

          Of course your using the newest and brightest with more bells and
          whistles than I'll ever be able to understand may well have introduced
          all kinds of new complications.

          Axel

          --
          Dipl.-Ing. F. Axel Berger Tel: +49/ 2174/ 7439 07
          Johann-H�ck-Str. 14 Fax: +49/ 2174/ 7439 68
          D-51519 Odenthal-Heide eMail: Axel-Berger@... <mailto:Axel-Berger%40Nexgo.De>
          Deutschland (Germany) http://berger-odenthal.de



          [Non-text portions of this message have been removed]
        • Alec Burgess
          John: I m not sure if this is directly relevant but this is how I execute/test external commands and capture the output. ... I ve put it on my clipbar for
          Message 4 of 6 , Jan 17, 2012
          • 0 Attachment
            John:
            I'm not sure if this is directly relevant but this is how I execute/test
            external commands and capture the output.
            > GetDOSOutput
            > ^!IfEmpty "^%theDosCommand%" Next Else Skip
            > ^!Set %theDosCommand%="dir "C:\""
            > ^!set %theDosCommand%=^?{Dos command=^%theDosCommand%}
            > ^!InsertText ^%theDosCommand% 2>&1^p
            > ^$GetDosOutput("^%theDosCommand%" 2>&1)$
            > ;end of clip
            I've put it on my clipbar for ready access whenever needed.

            On 2012-01-17 18:46, John Shotsky wrote:
            > I would like to execute a command from NoteTab which is intended to
            > operate from within a cmd box. When I do it
            > manually, the command works, so I know the command is structured
            > correctly. However, I can't figure out a way to execute
            > the same command from within NoteTab. I see the cmd window flash by,
            > but the command is not executed. What I need to do
            > is SUBMIT a command to the cmd box, but I'm not sure how to set that
            > up from within Notetab. I've written a dos .bat
            > file that does the same thing: when I run it from a cmd box, it works,
            > but if I try to execute it from Win 7, it
            > doesn't. I've tried both ^!DOS and &!Shell, but neither works as needed.
            >
            > I wrote a dir.bat command to execute from Win7, and that appears to
            > work. Of course, it uses a built in command rather
            > than an external command. It appears to me that the path for the
            > external command is flashed by when the dos window goes
            > by, but that's about one second, and I can't read the rest of it. When
            > I type 'java' from within the cmd box, I get the
            > help information, so I know the path is set right.
            >
            > For what it's worth, this is the command that works when executed from
            > within the cmd window AND when executed through
            > the .bat file within the cmd window, but not when executed using a
            > .bat file in win7 or from within NoteTab.
            > java -jar d:\cb2cb\McxExtract.jar -i d:\WorkImage\CL1986.mcx

            --
            Regards ... Alec (buralex@gmail & WinLiveMess - alec.m.burgess@skype)
          • John Shotsky
            When I added the full path to Java inside the batch file, it made no difference. It still runs in a cmd window, and not otherwise. I have verified that my cmd
            Message 5 of 6 , Jan 17, 2012
            • 0 Attachment
              When I added the full path to Java inside the batch file, it made no difference. It still runs in a cmd window, and not
              otherwise. I have verified that my cmd window opens with admin privileges.

              Regards,
              John
              RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

              From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
              Sent: Tuesday, January 17, 2012 16:08
              To: ntb-clips@yahoogroups.com
              Subject: Re: [Clip] Running commands in CMD box


              John Shotsky wrote:
              > It appears to me that the path for the external command is flashed
              > by when the dos window goes by, but that's about one second,

              I place most of my commands inside batch files (.bat), so I have more
              than one line, and end all of them with a <pause> command to read any
              logs or error messages. Of course a batch will also allow you to insert
              all kinds of <echo> commands to check for things.

              One problem I have come across is paths. In the registry there is an
              entry block "App Paths" like this:
              ------------------------------------
              [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App
              Paths\Firefox.exe]
              @="F:\\Winprog\\Mozilla_Firefox\\Firefox.exe"
              "Path"="F:\\Winprog\\Mozilla_Firefox"
              ------------------------------------

              So on just typing "firefox mypage.htm" in "Run", Windows will know where
              to find the program. Using "^!Shell firefox.exe mypage.htm" this
              information seems not to be avalilable and I have to prepend the program
              with its full path. The same is true when calling programs from a batch
              (I learnt the hard way). This doesn't make it easier running the same
              batch on different machines, unless you're extremely disciplined in
              installing all programs in exactly the same way, as I keep being
              reminded every second day.

              Of course your using the newest and brightest with more bells and
              whistles than I'll ever be able to understand may well have introduced
              all kinds of new complications.

              Axel

              --
              Dipl.-Ing. F. Axel Berger Tel: +49/ 2174/ 7439 07
              Johann-H�ck-Str. 14 Fax: +49/ 2174/ 7439 68
              D-51519 Odenthal-Heide eMail: Axel-Berger@... <mailto:Axel-Berger%40Nexgo.De>
              Deutschland (Germany) http://berger-odenthal.de



              [Non-text portions of this message have been removed]
            • Eb
              John, Like Alec, I have found the dos function better than the Shell or Cmd commands. First, you ll have to hard-code the path to Java. Look it up in the
              Message 6 of 6 , Jan 24, 2012
              • 0 Attachment
                John,

                Like Alec, I have found the dos function better than the Shell or Cmd commands.

                First, you'll have to hard-code the path to Java. Look it up in the programs folder:

                On 64-bit machines:
                ^!Set %path%="C:\Program Files (x86)\Java\jre6\bin"
                On 32-bit OS:
                ^!Set %path%="C:\Program Files\Java\jre6\bin"

                If the paths above don't work, convert them to DosShort.

                Then use multiple dos commands in a single NoteTab function to set the path, and then call java without path (command split to several lines for clarity, recombine these lines without adding the extra spaces):

                ^!Set %returns%=
                ^$GetDosOutput(
                cmd.exe /c set path=%path%;^%path%
                &&
                java -jar d:\cb2cb\McxExtract.jar -i d:\WorkImage\CL1986.mcx
                ;")$


                Cheers,

                Eb.


                --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
                >
                > I would like to execute ...

                > java -jar d:\cb2cb\McxExtract.jar -i d:\WorkImage\CL1986.mcx
              Your message has been successfully submitted and would be delivered to recipients shortly.