Solved

Pass parameters to a running process

Posted on 2008-10-09
5
847 Views
Last Modified: 2013-11-07
Hi guys!

Any tips how to pass parameters to an running process?

and with that I mean is not when I start the process I need to pass parameters when the process is already running.
0
Comment
Question by:AWestEng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 22678874
Are you sure process accepts params during run. May be you want to hack it ;-)

I
0
 
LVL 2

Assisted Solution

by:MTEXX
MTEXX earned 100 total points
ID: 22679146
Without knowing what application you are thinking about, it is impossible to say.
But if you are writing the application, then here are a few tools you can use:

- inter process communication / shared memory
- writing / reading to a file or directory
- connecting to a socket
- firing off another instance of that module using command arguments
- sendMessage and postMessage
- directly manipulating in-process memory

If you are indeed referring to an existing software product, please tell us what it is.

Cheers!
0
 
LVL 1

Author Comment

by:AWestEng
ID: 22679276
Both application is coded by me
from the Main App. I do this..
When TestApp is up and runing I need to pass a parameter to TestApp so I can close it correctly, I can't use the kill process, I need to run some code in TestApp before it closes.
 

'// Code from Main App
Dim myProcess As Process = New Process() 
myProcess.StartInfo.FileName = applicationPath & "TestApp.exe" 
Me.LaunchedProcess = myProcess 
myProcess.Start() 
 
Private Property LaunchedProcess() As Process 
   Get 
      Return m_serverProcess 
   End Get 
   Set(ByVal Value As Process) 
      m_serverProcess = Value 
   End Set 
End Property 

Open in new window

0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 400 total points
ID: 22680133
Like I said earlier AWestEng, the easiest way to do this is to make your app use the default Application Framework Events and make it a Single Instance Application.  Then you can call your EXE again with command-line parameters and it will fire the StartupNextInstance() event in your ORIGINAL application.  From there you can access the parameters and make code in the already running instance fire:

My.Application.StartupNextInstance()
http://msdn.microsoft.com/en-us/library/b9z4eyh8.aspx

Overview of the Visual Basic Application Model
http://msdn.microsoft.com/en-us/library/w3xx6ewx.aspx

I will be working on the code in your other PAQs today...  =)
0
 
LVL 1

Author Comment

by:AWestEng
ID: 22680225
thx m8.
I have change to the default Application Framework as you can see in the other PAQ.
 
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…

738 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