473,545 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

standardoutput for already running process

2 New Member
First off, hello everyone. This site has helped me find answeres to numberous questions.

What I want to make is a kill tracker for Wolfenstein enemy territory and I want the program to find kills and deaths in the game by reading from the console. W:ET is a quake 3 based game and I am not positive that this is the correct method for this but it would still be good to know in the future.

I want the program to find the game when and if it is running
Expand|Select|Wrap|Line Numbers
  1.     Private Sub getProcesses(ByVal source As Object, ByVal e As System.Timers.ElapsedEventArgs)
  2.        Dim dv As Integer = 0
  3.         Try
  4.             Dim ArrayProcess As Process() = Process.GetProcesses(MachineName)
  5.             Dim TempProcess As Process
  6.             For Each TempProcess In ArrayProcess
  7.                 Dim fmstr As String = "{0,-20}{1,5}"
  8.                 If TempProcess.ProcessName = "ET" Then
  9.                     lbl_gamestate.Text = "W:ET is running!"
  10.                     refreshT.Enabled = False
  11.                     gameRunning(TempProcess)
  12.                     Exit For
  13.                 Else
  14.                     lbl_gamestate.Text = "W:ET is not running!"
  15.                 End If
  16.             Next TempProcess
  17.         Catch ex As Exception
  18.             Throw New Exception(ex.Message)
  19.         End Try
  20.     End Sub
Now I tried to get the output into a listbox but I also tried a richtextbox but the code doesnt seem to get that far
Expand|Select|Wrap|Line Numbers
  1.     Private Sub gameRunning(ByVal gameprocess As Process)
  2.         Dim sr As IO.StreamReader = gameprocess.StandardOutput
  3.         Dim sb As New System.Text.StringBuilder
  4.         Dim input As Integer = sr.Read
  5.         Do Until input = -1
  6.             sb.Append(ChrW(input))
  7.             input = sr.Read
  8.             ListBox1.Items.Add(sr.ReadLine)
  9.             MsgBox("durt")
  10.         Loop
  11.         If gameprocess.HasExited Then
  12.             MsgBox("Game has closed!")
  13.         End If
  14.     End Sub
But it seems that the code hangs up at "Dim sr As IO.StreamReader = gameprocess.Sta ndardOutput" and wont go any farther. It doesn't give an error message nor does it crash the program.

I thought it might have had something to do with RedirectStandar dError and/or RedirectStandar dOutput so I tried this
Expand|Select|Wrap|Line Numbers
  1.     Private Sub gameRunning(ByVal gameprocess As Process)
  2.         gameprocess.Kill()
  3.         Dim et As New Process
  4.         Dim filename As String = "c:\program files\wolfenstein - enemy territory" & "\" & "et.exe"
  5.  
  6.         Try
  7.             If Exists(filename) Then
  8.                 et.StartInfo.Arguments = ""
  9.                 et.StartInfo.WorkingDirectory = "c:\program files\wolfenstein - enemy territory"
  10.                 et.StartInfo.FileName = "et.exe"
  11.                 et.StartInfo.RedirectStandardError = True
  12.                 et.StartInfo.RedirectStandardOutput = True
  13.                 et.Start()
  14.             Else
  15.                 MsgBox("Blue Monkey Patch Selector was not installed correctly." & Chr(13) & "Please reinstall the program.")
  16.             End If
  17.         Catch ex As Exception
  18.  
  19.         End Try
  20.  
  21.         Dim sr As System.IO.StreamReader = et.StandardOutput
  22.         Dim sre As System.IO.StreamReader = et.StandardError
  23.  
  24.         richtextbox1.Text = sr.ReadToEnd
  25.         richtextbox1.Text = sre.ReadToEnd
  26.  
  27.  
  28.         et.WaitForExit()
  29.         startRefresh()
  30.  
  31.     End Sub
But this time it stops at et.StartInfo.Re directStandardE rror = True and does not continue. If anyone can tell me what is wrong or has a better solution please let me know.

THX :-D
Mar 20 '07 #1
3 1412
willakawill
1,646 Top Contributor
Moved your thread to the .net forum
Mar 20 '07 #2
Clutch152
2 New Member
anyone there?
Mar 31 '07 #3
kenobewan
4,871 Recognized Expert Specialist
Welcome to the site. Guess that I'm not enough of a nerd to offer advice on gaming ;). Anyone else? All I can suggest is keep debugging.
Mar 31 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
412
by: John Lewin | last post by:
I've recently discovered the value of using existing console applications in managed .net apps. Unfortunately, I've stumbled into a problem with a particular console application that check's crc info on CDs. Using either the StandardError or StandardOutput streams read, readline or peek methods causes an immediate block that doesn't release...
3
10384
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...
15
3079
by: Matt Burland | last post by:
I'm having a problem with redirecting the StandardOutput of a process that I use to run a DOS program in my application. The problem is that I when I start my process (which I do in a separate thread) I can't read anything from the stdout before the process actually finishes. If I do something like this: Process myProcess = new...
1
8836
by: JC | last post by:
I'm trying to create a GUI wrapper for dumpbin, and so I'm using the Process class to run the command-line application. The problem is that if I use Readline() to get the output from the commandline app, it will hang when it comes to the command-prompt (there's no return to send it to readline). Here's the code: public bool...
1
1539
by: Jean Harris | last post by:
If I redirect the console output using the standard method, it works fine if the process outputs all its information and then exits quite soon. But for processes that output information as they are processing, for instance osql.exe when processing a large job, it doesn't seem that any of the read methods on StandardOutput are able to get the...
5
12770
by: vijaynats | last post by:
Hi I created a windows app to run a dos batch file (which takes around 5mins to complete and generates lots of output messages on the console in the meantime)and i used RedirectStandardOuput to display the output text in a textbox. The problem is that till the batch file has not finished running i don't get to see the output in the text...
0
1483
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...
2
2272
by: mwazir | last post by:
Hi all, I have a process thats starts in my application and only terminates when my application is terminated. I want to write the output and the errors of this process to a seperate log file. In order to do this, I spawned two threads. My code looks something like this ' Starting the process oProcessStartInfo = New ProcessStartInfo()
6
12801
by: Ole | last post by:
Hi, I'm running a command line process from my C# application trying to catch the output messages from the process into a textbox in my windows form. But the text doesn't update (the ReadLine doesn't return) until the process exits??? Any help is highly appreciated! The code is like this: Process myProcess = new Process();...
0
7499
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7432
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...
0
7943
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...
1
7456
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...
0
7786
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...
0
6022
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...
0
3490
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...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
743
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...

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.