473,378 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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.StartInfo.FileName = myAppName;
ExtProcess.StartInfo.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 7447
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.com

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

I want to run an external app from an assembly. Simple enough...
Process ExtProcess = new Process();
ExtProcess.StartInfo.FileName = myAppName;
ExtProcess.StartInfo.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.StartInfo.FileName = "cmd";
ExtProcess.StartInfo.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**********@community.nospam> wrote:
Hi all,

I want to run an external app from an assembly. Simple enough...
Process ExtProcess = new Process();
ExtProcess.StartInfo.FileName = myAppName;
ExtProcess.StartInfo.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***@removethis.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
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...
2
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 --...
2
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...
2
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...
7
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...
0
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....
5
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...
14
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,...
7
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.