?
Solved

calling .exe from console application

Posted on 2011-10-12
3
Medium Priority
?
334 Views
Last Modified: 2012-08-14
I had an .exe which returns a string

i want to test whether it really returns a string...

so how can i do that...

can i create a console application to call that .exe

i need to pass an argument along with that .exe

suppose let us say that the .exe application is mytest.exe

i called it from command line as below...

mytest a b c

it should return abcabcabc

code is written properly and .exe is build

only thing i need to test is i want to call this .exe from a .net console application and handle the return type from this .exe

so can some one send me a sample console application of how to call .exe  with parameters which returns a string
0
Comment
Question by:shragi
3 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 36957954
But in your applications you can check what args was passed.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36958046
What do you mean by, "I had an .exe which returns a string." Console applications typically return integer values indicating a success/failure code. Are you saying you are writing a string out to the Console window? If so, that is not actually returning anything; it is just writing something to your application's STDOUT.
0
 
LVL 17

Accepted Solution

by:
Carlos Villegas earned 2000 total points
ID: 36958237
Hello, with this code you can run an external app and capture the text wrote by that external application to it standard output (what I think you meant when you said returns a string):
Sub RunMyExternalApp()
    Dim myExternalAppExePath As String = "c:\temp\mytest.exe"
    Dim myExternalAppExeArguments As String = "a b c"

    Dim psi As New System.Diagnostics.ProcessStartInfo(myExternalAppExePath, myExternalAppExeArguments)
    psi.UseShellExecute = False
    psi.RedirectStandardOutput = True

    Dim myStandardOutputText As String
    Using myProcess As System.Diagnostics.Process = Process.Start(psi)
        myProcess.WaitForExit()
        ' Get the Standard Output Text
        myStandardOutputText = myProcess.StandardOutput.ReadToEnd()
    End Using

    'myStandardOutputText will contain the text wrote by your external app.
End Sub

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question