Attempt to hide console using Command line, Run, Exec and Pipe in VBScript












0















I'm using Zbarimg which (I believe) outputs its data to STDOUT. So at present, a cmd string within a VBScript executes the command and stores it in a variable, thus:



xml_data=objShell.Exec("C:MobiEventZbarbinzbarimg -D -q --xml C:MobiEventAllPics*.jpg").stdout.readall


(For the uninitiated, -D stops it displaying an image of the barcode it reads from image, and -q keeps things quiet so only the XML data is output) That all works well with all the data of AllPics being stored in xml_data. Problem is, as ever, the console pops up a window that stays open whilst the script processes. And with 200+ photos, it stays open a while



The alternative is to use the Run command, and tag ",0,False" onto the end ... but then of course, the StdOut output is not picked up for post processing!



I'm wondering if it could be possible to combine the two using a pipe, my THEORETICAL syntax being ...



objShell.Run("C:MobiEventZbarbinzbarimg -D -q --xml C:MobiEventAllPics*.jpg"|to other script),0,True


** Not even sure if the program would do that as it may read the pipe as part of the directory path



Which then beggars the next question. If it =is= possible to pipe out the STDOUT, how do I read that piped output back into a second VBScript program? (All I need to do is get the output of the program to print out to a file so that I can post process by reading in again and splitting it into component parts to derive the photo filename and the QR value)



I know this "Run=hide window / Exec=cannot hide" debate has raged for a while. Just wondered if the above MIGHT prove an alternative option.










share|improve this question



























    0















    I'm using Zbarimg which (I believe) outputs its data to STDOUT. So at present, a cmd string within a VBScript executes the command and stores it in a variable, thus:



    xml_data=objShell.Exec("C:MobiEventZbarbinzbarimg -D -q --xml C:MobiEventAllPics*.jpg").stdout.readall


    (For the uninitiated, -D stops it displaying an image of the barcode it reads from image, and -q keeps things quiet so only the XML data is output) That all works well with all the data of AllPics being stored in xml_data. Problem is, as ever, the console pops up a window that stays open whilst the script processes. And with 200+ photos, it stays open a while



    The alternative is to use the Run command, and tag ",0,False" onto the end ... but then of course, the StdOut output is not picked up for post processing!



    I'm wondering if it could be possible to combine the two using a pipe, my THEORETICAL syntax being ...



    objShell.Run("C:MobiEventZbarbinzbarimg -D -q --xml C:MobiEventAllPics*.jpg"|to other script),0,True


    ** Not even sure if the program would do that as it may read the pipe as part of the directory path



    Which then beggars the next question. If it =is= possible to pipe out the STDOUT, how do I read that piped output back into a second VBScript program? (All I need to do is get the output of the program to print out to a file so that I can post process by reading in again and splitting it into component parts to derive the photo filename and the QR value)



    I know this "Run=hide window / Exec=cannot hide" debate has raged for a while. Just wondered if the above MIGHT prove an alternative option.










    share|improve this question

























      0












      0








      0








      I'm using Zbarimg which (I believe) outputs its data to STDOUT. So at present, a cmd string within a VBScript executes the command and stores it in a variable, thus:



      xml_data=objShell.Exec("C:MobiEventZbarbinzbarimg -D -q --xml C:MobiEventAllPics*.jpg").stdout.readall


      (For the uninitiated, -D stops it displaying an image of the barcode it reads from image, and -q keeps things quiet so only the XML data is output) That all works well with all the data of AllPics being stored in xml_data. Problem is, as ever, the console pops up a window that stays open whilst the script processes. And with 200+ photos, it stays open a while



      The alternative is to use the Run command, and tag ",0,False" onto the end ... but then of course, the StdOut output is not picked up for post processing!



      I'm wondering if it could be possible to combine the two using a pipe, my THEORETICAL syntax being ...



      objShell.Run("C:MobiEventZbarbinzbarimg -D -q --xml C:MobiEventAllPics*.jpg"|to other script),0,True


      ** Not even sure if the program would do that as it may read the pipe as part of the directory path



      Which then beggars the next question. If it =is= possible to pipe out the STDOUT, how do I read that piped output back into a second VBScript program? (All I need to do is get the output of the program to print out to a file so that I can post process by reading in again and splitting it into component parts to derive the photo filename and the QR value)



      I know this "Run=hide window / Exec=cannot hide" debate has raged for a while. Just wondered if the above MIGHT prove an alternative option.










      share|improve this question














      I'm using Zbarimg which (I believe) outputs its data to STDOUT. So at present, a cmd string within a VBScript executes the command and stores it in a variable, thus:



      xml_data=objShell.Exec("C:MobiEventZbarbinzbarimg -D -q --xml C:MobiEventAllPics*.jpg").stdout.readall


      (For the uninitiated, -D stops it displaying an image of the barcode it reads from image, and -q keeps things quiet so only the XML data is output) That all works well with all the data of AllPics being stored in xml_data. Problem is, as ever, the console pops up a window that stays open whilst the script processes. And with 200+ photos, it stays open a while



      The alternative is to use the Run command, and tag ",0,False" onto the end ... but then of course, the StdOut output is not picked up for post processing!



      I'm wondering if it could be possible to combine the two using a pipe, my THEORETICAL syntax being ...



      objShell.Run("C:MobiEventZbarbinzbarimg -D -q --xml C:MobiEventAllPics*.jpg"|to other script),0,True


      ** Not even sure if the program would do that as it may read the pipe as part of the directory path



      Which then beggars the next question. If it =is= possible to pipe out the STDOUT, how do I read that piped output back into a second VBScript program? (All I need to do is get the output of the program to print out to a file so that I can post process by reading in again and splitting it into component parts to derive the photo filename and the QR value)



      I know this "Run=hide window / Exec=cannot hide" debate has raged for a while. Just wondered if the above MIGHT prove an alternative option.







      command-line shell vbscript






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 2 '15 at 14:15









      Chris BrownChris Brown

      613




      613






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I've no idea about your specific piece of software, but you can pipe and you can redirect in vbScript using the .Run command. For example:



          ' demonstrate piping and redirecting output with .Run
          Set objShell = WScript.CreateObject("WScript.Shell")
          Set objFSO = CreateObject("Scripting.FileSystemObject")
          strTemp=objShell.ExpandEnvironmentStrings("%TEMP%") & ""
          strCmd=objShell.ExpandEnvironmentStrings("%comspec%") & " /C"

          ' here is the action
          objShell.Run strCmd & "echo hello and welcome|findstr /N welcome >" & strTemp & "test.txt",0, True

          ' read the file back to show it was created successfully
          Set file = objFSO.OpenTextFile(strTemp & "test.txt", 1)
          strTaskText = file.ReadAll
          strTaskText=Left(strTaskText,Len(strTaskText)-2) ' remove trailing vbCrLf
          file.Close

          MsgBox "The output was:" & vbcrlf & strTaskText





          share|improve this answer
























          • Thanks for this. I'll try it tomorrow as nearly time to end the working day in UK!! (That said, I don't know what "findstr /N" is doing. I think strTemp is just to provide SOMETHING to print??) All I know about zbarimg is it sends its output to STDOUT, so providing a pipe also uses STDOUT, we should be in business. Will report Wed how I get on

            – Chris Brown
            Mar 2 '15 at 18:11











          • this is just an example, all FINDSTR does in this case is to find a string containing 'welcome' in the text passed ot it and print it out put the line number (1:) in front of it. The effect is that it outputs '1: hello and welcome' and this demonstrates that the text has been processed by it.

            – gogoud
            Mar 2 '15 at 19:10











          • I didn't use the "|" (pipe in perl, but here?) The ">" redirect worked fine, and is working fine. So I can now run Zbarimag, and then ExifTools, and both stay "hidden" and no pop-up console windows. (I;ve now also added a timed shell.PopUp so I can provide a sudo status report to show script it still progressing. Thanks for your input, and for explaining what findstr was doing

            – Chris Brown
            Mar 4 '15 at 18:56











          • The | is a pipe in windows and in linux generally, just like in perl. Glad you got it working.

            – gogoud
            Mar 4 '15 at 21:50











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f884521%2fattempt-to-hide-console-using-command-line-run-exec-and-pipe-in-vbscript%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I've no idea about your specific piece of software, but you can pipe and you can redirect in vbScript using the .Run command. For example:



          ' demonstrate piping and redirecting output with .Run
          Set objShell = WScript.CreateObject("WScript.Shell")
          Set objFSO = CreateObject("Scripting.FileSystemObject")
          strTemp=objShell.ExpandEnvironmentStrings("%TEMP%") & ""
          strCmd=objShell.ExpandEnvironmentStrings("%comspec%") & " /C"

          ' here is the action
          objShell.Run strCmd & "echo hello and welcome|findstr /N welcome >" & strTemp & "test.txt",0, True

          ' read the file back to show it was created successfully
          Set file = objFSO.OpenTextFile(strTemp & "test.txt", 1)
          strTaskText = file.ReadAll
          strTaskText=Left(strTaskText,Len(strTaskText)-2) ' remove trailing vbCrLf
          file.Close

          MsgBox "The output was:" & vbcrlf & strTaskText





          share|improve this answer
























          • Thanks for this. I'll try it tomorrow as nearly time to end the working day in UK!! (That said, I don't know what "findstr /N" is doing. I think strTemp is just to provide SOMETHING to print??) All I know about zbarimg is it sends its output to STDOUT, so providing a pipe also uses STDOUT, we should be in business. Will report Wed how I get on

            – Chris Brown
            Mar 2 '15 at 18:11











          • this is just an example, all FINDSTR does in this case is to find a string containing 'welcome' in the text passed ot it and print it out put the line number (1:) in front of it. The effect is that it outputs '1: hello and welcome' and this demonstrates that the text has been processed by it.

            – gogoud
            Mar 2 '15 at 19:10











          • I didn't use the "|" (pipe in perl, but here?) The ">" redirect worked fine, and is working fine. So I can now run Zbarimag, and then ExifTools, and both stay "hidden" and no pop-up console windows. (I;ve now also added a timed shell.PopUp so I can provide a sudo status report to show script it still progressing. Thanks for your input, and for explaining what findstr was doing

            – Chris Brown
            Mar 4 '15 at 18:56











          • The | is a pipe in windows and in linux generally, just like in perl. Glad you got it working.

            – gogoud
            Mar 4 '15 at 21:50
















          0














          I've no idea about your specific piece of software, but you can pipe and you can redirect in vbScript using the .Run command. For example:



          ' demonstrate piping and redirecting output with .Run
          Set objShell = WScript.CreateObject("WScript.Shell")
          Set objFSO = CreateObject("Scripting.FileSystemObject")
          strTemp=objShell.ExpandEnvironmentStrings("%TEMP%") & ""
          strCmd=objShell.ExpandEnvironmentStrings("%comspec%") & " /C"

          ' here is the action
          objShell.Run strCmd & "echo hello and welcome|findstr /N welcome >" & strTemp & "test.txt",0, True

          ' read the file back to show it was created successfully
          Set file = objFSO.OpenTextFile(strTemp & "test.txt", 1)
          strTaskText = file.ReadAll
          strTaskText=Left(strTaskText,Len(strTaskText)-2) ' remove trailing vbCrLf
          file.Close

          MsgBox "The output was:" & vbcrlf & strTaskText





          share|improve this answer
























          • Thanks for this. I'll try it tomorrow as nearly time to end the working day in UK!! (That said, I don't know what "findstr /N" is doing. I think strTemp is just to provide SOMETHING to print??) All I know about zbarimg is it sends its output to STDOUT, so providing a pipe also uses STDOUT, we should be in business. Will report Wed how I get on

            – Chris Brown
            Mar 2 '15 at 18:11











          • this is just an example, all FINDSTR does in this case is to find a string containing 'welcome' in the text passed ot it and print it out put the line number (1:) in front of it. The effect is that it outputs '1: hello and welcome' and this demonstrates that the text has been processed by it.

            – gogoud
            Mar 2 '15 at 19:10











          • I didn't use the "|" (pipe in perl, but here?) The ">" redirect worked fine, and is working fine. So I can now run Zbarimag, and then ExifTools, and both stay "hidden" and no pop-up console windows. (I;ve now also added a timed shell.PopUp so I can provide a sudo status report to show script it still progressing. Thanks for your input, and for explaining what findstr was doing

            – Chris Brown
            Mar 4 '15 at 18:56











          • The | is a pipe in windows and in linux generally, just like in perl. Glad you got it working.

            – gogoud
            Mar 4 '15 at 21:50














          0












          0








          0







          I've no idea about your specific piece of software, but you can pipe and you can redirect in vbScript using the .Run command. For example:



          ' demonstrate piping and redirecting output with .Run
          Set objShell = WScript.CreateObject("WScript.Shell")
          Set objFSO = CreateObject("Scripting.FileSystemObject")
          strTemp=objShell.ExpandEnvironmentStrings("%TEMP%") & ""
          strCmd=objShell.ExpandEnvironmentStrings("%comspec%") & " /C"

          ' here is the action
          objShell.Run strCmd & "echo hello and welcome|findstr /N welcome >" & strTemp & "test.txt",0, True

          ' read the file back to show it was created successfully
          Set file = objFSO.OpenTextFile(strTemp & "test.txt", 1)
          strTaskText = file.ReadAll
          strTaskText=Left(strTaskText,Len(strTaskText)-2) ' remove trailing vbCrLf
          file.Close

          MsgBox "The output was:" & vbcrlf & strTaskText





          share|improve this answer













          I've no idea about your specific piece of software, but you can pipe and you can redirect in vbScript using the .Run command. For example:



          ' demonstrate piping and redirecting output with .Run
          Set objShell = WScript.CreateObject("WScript.Shell")
          Set objFSO = CreateObject("Scripting.FileSystemObject")
          strTemp=objShell.ExpandEnvironmentStrings("%TEMP%") & ""
          strCmd=objShell.ExpandEnvironmentStrings("%comspec%") & " /C"

          ' here is the action
          objShell.Run strCmd & "echo hello and welcome|findstr /N welcome >" & strTemp & "test.txt",0, True

          ' read the file back to show it was created successfully
          Set file = objFSO.OpenTextFile(strTemp & "test.txt", 1)
          strTaskText = file.ReadAll
          strTaskText=Left(strTaskText,Len(strTaskText)-2) ' remove trailing vbCrLf
          file.Close

          MsgBox "The output was:" & vbcrlf & strTaskText






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 2 '15 at 14:33









          gogoudgogoud

          9481611




          9481611













          • Thanks for this. I'll try it tomorrow as nearly time to end the working day in UK!! (That said, I don't know what "findstr /N" is doing. I think strTemp is just to provide SOMETHING to print??) All I know about zbarimg is it sends its output to STDOUT, so providing a pipe also uses STDOUT, we should be in business. Will report Wed how I get on

            – Chris Brown
            Mar 2 '15 at 18:11











          • this is just an example, all FINDSTR does in this case is to find a string containing 'welcome' in the text passed ot it and print it out put the line number (1:) in front of it. The effect is that it outputs '1: hello and welcome' and this demonstrates that the text has been processed by it.

            – gogoud
            Mar 2 '15 at 19:10











          • I didn't use the "|" (pipe in perl, but here?) The ">" redirect worked fine, and is working fine. So I can now run Zbarimag, and then ExifTools, and both stay "hidden" and no pop-up console windows. (I;ve now also added a timed shell.PopUp so I can provide a sudo status report to show script it still progressing. Thanks for your input, and for explaining what findstr was doing

            – Chris Brown
            Mar 4 '15 at 18:56











          • The | is a pipe in windows and in linux generally, just like in perl. Glad you got it working.

            – gogoud
            Mar 4 '15 at 21:50



















          • Thanks for this. I'll try it tomorrow as nearly time to end the working day in UK!! (That said, I don't know what "findstr /N" is doing. I think strTemp is just to provide SOMETHING to print??) All I know about zbarimg is it sends its output to STDOUT, so providing a pipe also uses STDOUT, we should be in business. Will report Wed how I get on

            – Chris Brown
            Mar 2 '15 at 18:11











          • this is just an example, all FINDSTR does in this case is to find a string containing 'welcome' in the text passed ot it and print it out put the line number (1:) in front of it. The effect is that it outputs '1: hello and welcome' and this demonstrates that the text has been processed by it.

            – gogoud
            Mar 2 '15 at 19:10











          • I didn't use the "|" (pipe in perl, but here?) The ">" redirect worked fine, and is working fine. So I can now run Zbarimag, and then ExifTools, and both stay "hidden" and no pop-up console windows. (I;ve now also added a timed shell.PopUp so I can provide a sudo status report to show script it still progressing. Thanks for your input, and for explaining what findstr was doing

            – Chris Brown
            Mar 4 '15 at 18:56











          • The | is a pipe in windows and in linux generally, just like in perl. Glad you got it working.

            – gogoud
            Mar 4 '15 at 21:50

















          Thanks for this. I'll try it tomorrow as nearly time to end the working day in UK!! (That said, I don't know what "findstr /N" is doing. I think strTemp is just to provide SOMETHING to print??) All I know about zbarimg is it sends its output to STDOUT, so providing a pipe also uses STDOUT, we should be in business. Will report Wed how I get on

          – Chris Brown
          Mar 2 '15 at 18:11





          Thanks for this. I'll try it tomorrow as nearly time to end the working day in UK!! (That said, I don't know what "findstr /N" is doing. I think strTemp is just to provide SOMETHING to print??) All I know about zbarimg is it sends its output to STDOUT, so providing a pipe also uses STDOUT, we should be in business. Will report Wed how I get on

          – Chris Brown
          Mar 2 '15 at 18:11













          this is just an example, all FINDSTR does in this case is to find a string containing 'welcome' in the text passed ot it and print it out put the line number (1:) in front of it. The effect is that it outputs '1: hello and welcome' and this demonstrates that the text has been processed by it.

          – gogoud
          Mar 2 '15 at 19:10





          this is just an example, all FINDSTR does in this case is to find a string containing 'welcome' in the text passed ot it and print it out put the line number (1:) in front of it. The effect is that it outputs '1: hello and welcome' and this demonstrates that the text has been processed by it.

          – gogoud
          Mar 2 '15 at 19:10













          I didn't use the "|" (pipe in perl, but here?) The ">" redirect worked fine, and is working fine. So I can now run Zbarimag, and then ExifTools, and both stay "hidden" and no pop-up console windows. (I;ve now also added a timed shell.PopUp so I can provide a sudo status report to show script it still progressing. Thanks for your input, and for explaining what findstr was doing

          – Chris Brown
          Mar 4 '15 at 18:56





          I didn't use the "|" (pipe in perl, but here?) The ">" redirect worked fine, and is working fine. So I can now run Zbarimag, and then ExifTools, and both stay "hidden" and no pop-up console windows. (I;ve now also added a timed shell.PopUp so I can provide a sudo status report to show script it still progressing. Thanks for your input, and for explaining what findstr was doing

          – Chris Brown
          Mar 4 '15 at 18:56













          The | is a pipe in windows and in linux generally, just like in perl. Glad you got it working.

          – gogoud
          Mar 4 '15 at 21:50





          The | is a pipe in windows and in linux generally, just like in perl. Glad you got it working.

          – gogoud
          Mar 4 '15 at 21:50


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f884521%2fattempt-to-hide-console-using-command-line-run-exec-and-pipe-in-vbscript%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

          Mangá

           ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕