473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How do I read standard output from a cmd window

My code
Dim Cmd As New Process
Dim CmdHandle As String
Dim dirResults As String
Cmd.StartInfo.FileName = "c:\working\gpg\gpg.exe"
Cmd.StartInfo.Arguments = "--yes --output :\working\inbound\test.txt
--decrypt c:\working\inbound\anstest.gpg"
Cmd.StartInfo.RedirectStandardInput = True
Cmd.StartInfo.RedirectStandardOutput = True
Cmd.StartInfo.UseShellExecute = False
Cmd.Start()

MsgBox("the name of the process", MsgBoxStyle.Information,
Cmd.ProcessName)
dirResults = Cmd.StandardOutput.ReadToEnd
MsgBox(dirResults)

The window pops up and is full of text but the dirResults string is
nothing.
Do I have to have a seperate thread to read the output?

Thanks,
Phil

Nov 21 '05 #1
1 2365
Hi,

Maybe this will help.
Dim pi As New ProcessStartInfo

Dim p As Process

pi.RedirectStandardOutput = True

pi.FileName = "c:\myconsoleapp.exe"

pi.UseShellExecute = False

Dim sw As New System.IO.StreamWriter("C:\MyOutPut.txt")

p = Process.Start(pi)

sw.WriteLine(p.StandardOutput.ReadToEnd)

p.WaitForExit()

sw.Close()

Ken

------------------------------------
"PAPutzback" <ph**************@insightbb.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
My code
Dim Cmd As New Process
Dim CmdHandle As String
Dim dirResults As String
Cmd.StartInfo.FileName = "c:\working\gpg\gpg.exe"
Cmd.StartInfo.Arguments = "--yes --output :\working\inbound\test.txt
--decrypt c:\working\inbound\anstest.gpg"
Cmd.StartInfo.RedirectStandardInput = True
Cmd.StartInfo.RedirectStandardOutput = True
Cmd.StartInfo.UseShellExecute = False
Cmd.Start()

MsgBox("the name of the process", MsgBoxStyle.Information,
Cmd.ProcessName)
dirResults = Cmd.StandardOutput.ReadToEnd
MsgBox(dirResults)

The window pops up and is full of text but the dirResults string is
nothing.
Do I have to have a seperate thread to read the output?

Thanks,
Phil
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Grzegorz | last post by:
Hello, I'm using eclipse with pydev plugin, I'm working on a program using wxpython . When I'm executing that application standard error output does not show in eclipse console window - wxpython...
7
by: Christian Schmitt | last post by:
Hi, I want to write a script that (run from a file on the local HD) reads another local html-file into a variable, then make some changes to it, and then output the result in a way that makes it...
3
by: Steve | last post by:
How can I read the output from a command line utility such as ping, nslookup, etc, from within my app??? I know that it is possible to output the results to a text file using the > function in a...
20
by: SR | last post by:
Hi, I need to read the output from a system( ) function within a C program. The function however only returns the exit status. How can I read what system( ) sends to stdout ? (is there a simpler...
1
by: Magix | last post by:
Hi, I have these string data: str_data1, str_data2, str_data3, which capture some value after a routine process A. Then I would like to write (append) these 3 string values into a text file each...
16
by: ben beroukhim | last post by:
I have huge number of legacy code which use standard files functions. I would like to pass a memory pointer rather than a FILE pointer. I am trying to use FILEs in the code to refer to memory...
3
by: Al Cohen | last post by:
I'll start by warning that I'm a newbie to C# (but I've been programming for 25 years), so I may just be doing something reallyreally dumb. I'm writing a C# wrapper for a command-line application...
4
by: Bill Cohagan | last post by:
I'm writing a console app (in C#) and I want to be able to redirect the standard input/output streams when it's run at a command prompt. IOW I want to support the "<" and ">" redirection syntax....
3
by: Bill Cohagan | last post by:
I'm writing a console app in c# and am encountering a strange problem. I'm trying to use redirection of the standard input stream to read input from a (xml) file. The following code snippet is from...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.