calling .exe from console application

Posted on 2011-10-12
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
Question by:shragi
    LVL 48

    Expert Comment

    But in your applications you can check what args was passed.
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    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.
    LVL 17

    Accepted Solution

    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)
            ' 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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now