0

I would like to pass the input of a txt-File to an application in VB.NET. Manually it would be something like

C:\file.exe -param < textfile.txt

Now I want to implement this part in VB.Net. I've tried the following options:

Process.Start(filepath, "-param < test.txt")

also tried

ProcessStartInfo.Arguments = "-param < test.txt"

or shell nothing seems to work for me.

Do you have an idea what I can do to pass the content of a file?

Best greetings

Chris
  • 25
  • 8
  • Your example seems to be to call `file.exe < textfile` ... but your other examples more look like `file.exe -param < textfile` ... so, could using "-param" cause that problem? Then "nothing seems to work" is not a helpful description of your problem. What exactly happens; and what did you expect to happen? – GhostCat Jan 03 '17 at 11:27
  • No that's not the problem, I've just forgot to mention the parameter in my example, sry – Chris Jan 03 '17 at 11:30
  • And I didnt think through. Your problem is this: http://stackoverflow.com/questions/1860563/redirecting-input-to-an-executable-from-excel-vba ... simply spoken: you can't pipe when making such kind of shell exec calls. Instead, **your code** has to use some programmatic means to **write** that text file into some stream that is seen as stdin to the invoked app. I am not a VB expert; so I hope the above link gives at least enough guidance for you to figure the solution. – GhostCat Jan 03 '17 at 11:39
  • Here is a C# answer for the problem noted by GhostCat - http://stackoverflow.com/questions/850802/piping-in-a-file-on-the-command-line-using-system-diagnostics-process – dbasnett Jan 03 '17 at 11:48
  • Alright I got it working until I need to pass a password to the application. Which is represented as ********* in the tool. If I pass the password-string using writeline (how I passed my username and other information) the program doesn't respond to my input. – Chris Jan 04 '17 at 08:10

0 Answers0