473,883 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Executing a DOS type command from VB.NET and retrieving its ouput

Please point me to some articles that explain how to execute a dos type
command and retrieve its output for processing.
Thanks.
Nov 22 '05 #1
3 3317
James,

Here beneath a simple sample, however did you know that there was a special
newsgroup for VB.net language
microsoft.publi c.dotnet.langua ges.vb

\\\
Public sub myStart() as String
Dim p As New Process
dim pi as new processstartinf o
pi.UseShellExec ute = False
pi.RedirectStan dardOutput = True
pi.Arguments = myargumentstrin g
pi.WorkingDirec tory = myworkdirectory string
pi..FileName =C:\myprogram
pi.startinfo = pi
p.Start()
Dim sr As IO.StreamReader = p.StandardOutpu t
Dim sb As New System.Text.Str ingBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW( input))
input = sr.Read
Loop
Return SB.tostring
///

I hope this helps?

Cor

"James D. Marshall" <cr**********@h otmail.com>
Please point me to some articles that explain how to execute a dos type
command and retrieve its output for processing.
Thanks.

Nov 22 '05 #2
Thank you that does help a lot.
One question on parsing, the line has double carriage returns that show up
as squares, I am seeing this through watch1, how would you code a replace
statement to get rid of these, its driving me batty.

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uc******** ******@TK2MSFTN GP15.phx.gbl...
James,

Here beneath a simple sample, however did you know that there was a
special newsgroup for VB.net language
microsoft.publi c.dotnet.langua ges.vb

\\\
Public sub myStart() as String
Dim p As New Process
dim pi as new processstartinf o
pi.UseShellExec ute = False
pi.RedirectStan dardOutput = True
pi.Arguments = myargumentstrin g
pi.WorkingDirec tory = myworkdirectory string
pi..FileName =C:\myprogram
pi.startinfo = pi
p.Start()
Dim sr As IO.StreamReader = p.StandardOutpu t
Dim sb As New System.Text.Str ingBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW( input))
input = sr.Read
Loop
Return SB.tostring
///

I hope this helps?

Cor

"James D. Marshall" <cr**********@h otmail.com>
Please point me to some articles that explain how to execute a dos type
command and retrieve its output for processing.
Thanks.


Nov 22 '05 #3
James,

Parsing can mean a lot in dotNet, so maybe better that you make a new
message, in this newsgroup or in the newsgroup I pointed you on. The last in
my idea better because VBNet has a lot of extra conversion functions which
make parsing easier. And as written by the VBNet development team better.

Cor

"James D. Marshall" <cr**********@h otmail.com>
Thank you that does help a lot.
One question on parsing, the line has double carriage returns that show up
as squares, I am seeing this through watch1, how would you code a replace
statement to get rid of these, its driving me batty.

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uc******** ******@TK2MSFTN GP15.phx.gbl...
James,

Here beneath a simple sample, however did you know that there was a
special newsgroup for VB.net language
microsoft.publi c.dotnet.langua ges.vb

\\\
Public sub myStart() as String
Dim p As New Process
dim pi as new processstartinf o
pi.UseShellExec ute = False
pi.RedirectStan dardOutput = True
pi.Arguments = myargumentstrin g
pi.WorkingDirec tory = myworkdirectory string
pi..FileName =C:\myprogram
pi.startinfo = pi
p.Start()
Dim sr As IO.StreamReader = p.StandardOutpu t
Dim sb As New System.Text.Str ingBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW( input))
input = sr.Read
Loop
Return SB.tostring
///

I hope this helps?

Cor

"James D. Marshall" <cr**********@h otmail.com>
Please point me to some articles that explain how to execute a dos type
command and retrieve its output for processing.
Thanks.



Nov 22 '05 #4

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

Similar topics

1
10925
by: Falk Schneider | last post by:
I wrote a PHP shell script under Linux which puts all existing PS-Files within a directory into a list and should then start a single Ghostview window for each file. Sounds simple, but it's not: The following code provides for about half of the functionality I wanted: ==============code starts $bla = array(); foreach ($filelist as $file)
1
1921
by: David Faden | last post by:
Hi, Given arbitrary Python source code input by the user, I want to get the result of executing that source as an expression if it is an expression and otherwise execute the source as a statement. Currently, I'm accomplishing this as follows (in a category on NSString), but it seems kludgy to rely on detecting a syntax error. - (PyObject*)executePythonSourceWithGlobals:(PyObject*)globals {
0
1972
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is inside a package, the invocation will fail with a "Module not found" error. This PEP is aimed at fixing that :) Cheers, Nick.
15
2622
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that for Python 2.5. Previously, posting of a draft version of the PEP to python-dev and python-list didn't actually generate any responses. I'm not sure if that's an indication that people don't see the restriction to top-level modules as a problem...
18
2253
by: Brad Pears | last post by:
Can someone give me some sample code on how one would go about executing a command line "command" from within an ASP form? We need to run an application called GnuPG which allows us to encrypt an email. Preferably some documentation directly on this would be good but any other docuemtnation on executing a command line "command" would be great! Thanks,
3
511
by: James D. Marshall | last post by:
Please point me to some articles that explain how to execute a dos type command and retrieve its output for processing. Thanks.
7
5582
by: clr | last post by:
I like to stamp trace logs with the name of the executing Class and Method. I can get the Class Name using GetType.Name and I can get a list of every Method in the class using System.Reflection.MethodInfo objects (code follows) But is there anyway to retrieve the name of the currently executing Method? Or is this a lost cause? (code sample) Dim sClassName as String = Me.GetType.Name Dim aMethod() as System.Reflection.MethodInfo =...
0
1505
by: BasicQ | last post by:
I am running an executable from my aspx page with the click of a button. A date is passed as an argument. I am able to get the standardoutput from the Process(Exe) into the label of my page after the process has completed executing. My problem is I need to get the output in the label simultaneously when the EXE is running, not after it has completed executing. Just like when I run the Exe in the cmd prompt. In my code I am opening two...
3
1690
by: Ara Kooser | last post by:
Hello all, I hope I am posting this correctly. I am running Python 2.4.2 on Slackware 11.0 using IDLE. I am in the process of learning python so I am writing a text adventure game using functions and global variables only. I know there is a better way to do this but that is for later. When I run the python program it works fine until I try to go west from my inital start room. I get the room description but no raw_input prompt. I just...
10
17716
by: lalnamar | last post by:
I want to execute a unix time command using perl, and capture the output (specifically, the time it takes the command to execute). i tried using the system command: system("time command "); however, when i try to capture the output, the capture output does not contain the amount of time it took to execute when i try to do: $var = `time command `; there is the same problem (the ouput from the command is saved in the variable; however,...
0
9792
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,...
1
10847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10416
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9574
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...
0
7129
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5991
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4612
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
4220
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3233
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.