[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 961
  • Last Modified:

Processes: StandardInput/StandardOutput

Hi guys!

I really need some help to sort this out!
The code I have dosent work so I need help to see what I have done wrong, EXPERT help needed!!!

I have 2 applications: App1 and App2
1: In App1 I send a command to App2
2: In App1 I like to know if this command was executed as it should, so I need some data back from App2

This is the code!

This is just pseudocode  
I  must use the process StandardInput/StandardOutput method, nothing else..

In App1
        Dim myprocess As New Process
        Dim processData As String
        With myprocess.StartInfo
            .FileName = applicationPath & server & ".exe"
            .Arguments() = "/input=True,True"
            .CreateNoWindow = False
            .ErrorDialog = False
            .UseShellExecute = False
            .RedirectStandardOutput = True
            .RedirectStandardError = True
            .RedirectStandardInput = True
            .WindowStyle = ProcessWindowStyle.Normal
        End With
        Dim standardOutput As IO.StreamReader = myProcess.StandardOutput
        '// Wait for Exited event, but not more than 10 seconds.
        Const SLEEP_AMOUNT As Integer = 100
        Do While Not m_shutDownProcessExited
            m_shutDownElapsedTime += SLEEP_AMOUNT
            '// Read the standard output of the spawned process.
            processData = standardOutput.ReadToEnd
            If Not String.IsNullOrEmpty(processData) Then
                Exit Do
            End If
            '// Timout?
            If m_shutDownElapsedTime > 10000 Then
                Exit Do
            End If
        If processData = "True" Then
            'Do some stuff
            ' Do some other stuff
        End If
In App2
        Dim runningProcesses As Process()
        Dim runningProcess As Process = Nothing
        runningProcesses = Process.GetProcessesByName(server.FullPath)
        If runningProcesses.Length > 0 Then
            For Each p As Process In runningProcesses
                If p.ProcessName = server.Name Then
                    runningProcess = p
                    Exit For
                End If
        End If
        If runningProcess IsNot Nothing Then
        End If

Open in new window

  • 5
1 Solution
try if this works

replace line 22 - 37 with
'// Wait for Exited event, but not more than 10 seconds.
processData = myprocess.ExitCode

'// wait a liitle more before killing the process

you wrote <<I  must use the process StandardInput/StandardOutput method, nothing else..>>
If that is a limitation ok, if not why not have your App2 write a text file e.g. "App2Results.txt" and look for this text file in a do/loop node from App1?

AWestEngAuthor Commented:
when using StandardInput/StandardOutput is it not possible to send stuff between the applicaitons when a instance is running, why doesen't my code work?
AWestEngAuthor Commented:
and in App2 should I write to input to send the data back to App1?
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

AWestEngAuthor Commented:
hmm I'll skipt the part of using the standardInput/output I'll connect via a socket instead, any tips there?
only local connection wil be used
AWestEngAuthor Commented:
when I tested some more now I got this error from app 2 > StandardIn has not been redirected
AWestEngAuthor Commented:
I can't get it to work as I want, but that can be my bad.. But thx for trying

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now