473,698 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pass input to a running process.

Hi all,

I want to run an external app from an assembly. Simple enough...
Process ExtProcess = new Process();
ExtProcess.Star tInfo.FileName = myAppName;
ExtProcess.Star tInfo.Arguments = myArgs;
...etc...


My problem is that the command I am cfalling produces an "Are you
sure?" message that is not overridable with a switch (eg. /y)

Is there any way for the framework to wait for the "Are you sure?"
string, and then send a response (in this case, "y")?

TIA
Marc.
Nov 17 '05 #1
4 7496
Marc,

What you could do is wait until a time you know that the application
will put up the message box, and then use the SendInput (through the
P/Invoke layer) to simulate the mouse click. Of course, you will have to
determine some way to find out when that message box is shown, and then send
the input. All in all, it's very hokey, but there is little you can do
about it, it would seem.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Marc Jennings" <Ma**********@c ommunity.nospam > wrote in message
news:ub******** *************** *********@4ax.c om...
Hi all,

I want to run an external app from an assembly. Simple enough...
Process ExtProcess = new Process();
ExtProcess.Star tInfo.FileName = myAppName;
ExtProcess.Star tInfo.Arguments = myArgs;
...etc...


My problem is that the command I am cfalling produces an "Are you
sure?" message that is not overridable with a switch (eg. /y)

Is there any way for the framework to wait for the "Are you sure?"
string, and then send a response (in this case, "y")?

TIA
Marc.

Nov 17 '05 #2
I found a workaround (as always happens just after I post a question,
never before...)

In this case, I am calling cacls.exe to set ACL on a file / folder.
Process ExtProcess = new Process();
ExtProcess.Star tInfo.FileName = "cmd";
ExtProcess.Star tInfo.Arguments = "/C echo Y| cacls /E /R user:F");
works a treat.

Thanks.
Marc.

On Wed, 20 Jul 2005 16:30:32 +0100, Marc Jennings
<Ma**********@c ommunity.nospam > wrote:
Hi all,

I want to run an external app from an assembly. Simple enough...
Process ExtProcess = new Process();
ExtProcess.Star tInfo.FileName = myAppName;
ExtProcess.Star tInfo.Arguments = myArgs;
...etc...


My problem is that the command I am cfalling produces an "Are you
sure?" message that is not overridable with a switch (eg. /y)

Is there any way for the framework to wait for the "Are you sure?"
string, and then send a response (in this case, "y")?

TIA
Marc.


Nov 17 '05 #3
Marc,
I want to run an external app from an assembly.
Is there any way for the framework to wait for the "Are you sure?"
string, and then send a response (in this case, "y")?


Is your process a console (text-mode) application? If so, you could use
something called "standard input/output redirection".

That is, .NET gives you access to the streams for input and out of the
console process (what it reads in and what it writes out), using the
StandardInput and StandardOutput properties of the Process class. If you
look at the .NET SDK Documentation for the StandardOutput property, you can
also find a simple example.

The idea is that you read the standard output until you find the "Are you
sure?" string, and then write the letter "y" (probably along with the Enter
key) to the standard input stream of the process.

That should solve your problem. GUI applications are a totally different
thing.

Hope this helps.

--
Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethi s.dystopia.fi
http://www.saunalahti.fi/janij/
Nov 17 '05 #4
Since it is a command line program, you can also redirect the standard
input and output and watch for the message and then send the response
back.

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2588
by: wesley | last post by:
Hello, How do I pass object to the current running process? For example my assembly is called program.exe. Once program.exe is running sometime I want to call it again ie: program.exe /m do_stuff Now how do I pass that "do_stuff" to the currently running instance?
2
3781
by: Moses M | last post by:
I need to get the the user name associated with a running process (Listed as "UserName" in Task Manager Window). The Process Class doesn't seem to provide a direct way for doing this! Thanks -- Moses
2
4574
by: Jacek | last post by:
Hello! My application has to use external native library writing to stdout and stdin. My goal is to redirect output within running process (no chance to do that in child process - Process class redirection is useless in that case) and I would like to do it without reverting to C-run time library P/Invoke calls. Any ideas how to do that?
2
1543
by: Scott Meddows | last post by:
Can you tell who owns a running process in .NET? I can do the system.diagnostic.process object and see if an application of the same name is running but I need to tell if the process is running by a current user or by another user. Anyone know how to do this? Thanks
7
2575
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently upgraded to VB.NET, and I have a lot of catching up to do. That being said, I have come a long way in a short while, however, I am stumped at the moment. I have read through days of posts, but have not been able to address my specific question, so...
0
1049
by: Patrick Dugan | last post by:
In VB6 we can attach to a running process in memory and transmit information back and forth. This allows us to have several different applications all accessing the same program running in memory. In VB.NET when we try this it fails. We use the objName.Start(Process Handle) function. It will indicate that the connection was sucessful but gets no response from the running process.
5
2021
by: xhy_China | last post by:
How to close an file in an running process from another process? For example: There are two running processes,named procIn and procFrom. A file named needCloseFile was opened in procIn. Now I want to close the needCloseFile from procFrom by programming,but left procIn running normally. What can I do???
14
23154
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So, we're looking for a way to display the page with a "please wait..." message while the process is running, and then, when the process is done, update the page with the actual results/page content. We have a page that opens another browser/page...
7
2696
by: sravan_reddy001 | last post by:
I want to handle a running process. ex: explorer.exe How can i handle that process(explorer.exe). and is it possilbe to stop that process from runing.
1
15642
by: shekoasinger | last post by:
Im working on a Dll Injector. But that is not my problem. I am using a picturebox to display the icon of a running process. E.g. If google chrome is running. The picturebox should display the icon of google chrome. I can extract the icon to my picturebox only if I know the full path of the process. That API was easily found and works very well. But know I want my application to get the full path of a running process automatically as soon...
0
8680
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.