redirect - Redirecting input to an executable from Excel VBA -


How do you redirect the input from the VBA to the executable? In particular, why do not the code given below work? WshShell = VBA.CreateObject ("WScript.Shell") WshShell.Run "runme & lt; start.txt", 1, true

P> or

  RetVal = Shell ("runname  

Runme.exe All rights are started, but the input is not redirected and it has to be typed manually in the command window. Also tried:

  RetVal = Shell ("type start.txt | runme.exe", vbNormalFocus)  

typed output pipe Start .txt in runme.exe returns a plain "file not found" error

However, when I type those different commands directly on the command line I do all that work.

I will answer the more general part of your question. You asked:

Specifically, why do not the code given below work?

WshShell.Run "runme & lt; start.txt", 1, true

The code does not work as expected The shell of WScript.Shell is not similar to the shell of cmd.exe, in particular, it does not redirect or pipe .

If you were able to debug the runam process, you would see that this two argument, & lt; and start.txt

As previously answered, there are two ways to fix this:

  • WScript feed. Skip STNI directly and delete your redirect

    set oExec = WshShell.exec (cmdLine)
    oExec.StdIn.Write "first sign Some input for "& amp; WshShell

  • .UN "% COMSPEC% / c runema" txt ", 1, true


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -