473,738 Members | 9,555 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 7511
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
3784
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
4579
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
1544
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
2577
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
1050
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
2025
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
23166
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
2701
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
15646
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
8788
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
9335
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...
1
9263
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.