473,748 Members | 10,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.F ileName = "c:\working\gpg \gpg.exe"
Cmd.StartInfo.A rguments = "--yes --output :\working\inbou nd\test.txt
--decrypt c:\working\inbo und\anstest.gpg "
Cmd.StartInfo.R edirectStandard Input = True
Cmd.StartInfo.R edirectStandard Output = True
Cmd.StartInfo.U seShellExecute = False
Cmd.Start()

MsgBox("the name of the process", MsgBoxStyle.Inf ormation,
Cmd.ProcessName )
dirResults = Cmd.StandardOut put.ReadToEnd
MsgBox(dirResul ts)

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 2386
Hi,

Maybe this will help.
Dim pi As New ProcessStartInf o

Dim p As Process

pi.RedirectStan dardOutput = True

pi.FileName = "c:\myconsoleap p.exe"

pi.UseShellExec ute = False

Dim sw As New System.IO.Strea mWriter("C:\MyO utPut.txt")

p = Process.Start(p i)

sw.WriteLine(p. StandardOutput. ReadToEnd)

p.WaitForExit()

sw.Close()

Ken

------------------------------------
"PAPutzback " <ph************ **@insightbb.co m> wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.com.. .
My code
Dim Cmd As New Process
Dim CmdHandle As String
Dim dirResults As String
Cmd.StartInfo.F ileName = "c:\working\gpg \gpg.exe"
Cmd.StartInfo.A rguments = "--yes --output :\working\inbou nd\test.txt
--decrypt c:\working\inbo und\anstest.gpg "
Cmd.StartInfo.R edirectStandard Input = True
Cmd.StartInfo.R edirectStandard Output = True
Cmd.StartInfo.U seShellExecute = False
Cmd.Start()

MsgBox("the name of the process", MsgBoxStyle.Inf ormation,
Cmd.ProcessName )
dirResults = Cmd.StandardOut put.ReadToEnd
MsgBox(dirResul ts)

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
4041
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 seems to redirect standard output to some another window , and closes that window immediately, so I can't see any error messagess. Is there a way to redirect standard output to eclipse console ?
7
18559
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 simple for the user to save it again. And all of this should run in any current browser, not just IE. I managed to access the code of the current document by code = document.documentElement.innerHTML
3
4424
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 command window and then read the file, but doing this for 1000+ files will cause a lot of unnecessary read/writes to the disc and affect performance... I am not asking for a .NET way to ping or do a DNS lookup, I am interested in the concept of...
20
13129
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 way than having to fork a child process and then catching its output ?) (if needed: working on linux) Thanks
1
4308
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 time after routine process A, the text file is named "mytext.dat" in following format with "#####" as separator. The maximum entries of them is 5. When reaching the fifth entry, it will delete the very first entry.
16
3498
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 buffers. Basically, I want to be able to use all the standard read and write functions, but I want them to refer to memory locations, rather than disk files. I do not want to touch the legacy code. Does any one know of a library
3
10405
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 (pscp.exe, a secure file-copy app that's part of the excellent PuTTY SSH package). Getting pscp.exe to run properly was a piece of cake using the System.Diagnostics.Process class. The thing that I can't get to work is the ability to read...
4
8740
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. The obvious way to do this is by using the static Console type properties, In and Out. When trying to debug the app in the IDE however, this doesn't appear to work. I've edited the project properties and added the necessary text to the "command...
3
2754
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 this app: =============================== static void Main(string args) { if (args.Length > 0) Console.SetIn(new StreamReader(args)); //executes if I don't use the "<", ">" redirection syntax when invoking XmlTextReader xmlin = new...
0
8823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8237
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.