Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
How to execute the exe files after website is hosted in iis? i am using iis 5.1. below is the code i am using
C#
var p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"C:\\Program Files\\ComponentSoftware\\CSDiff\\CSDiff.exe";

                  p.Start();


this works fine from localhost but not from iis. How to solve this issue?
thanks in advance
Posted
Comments
[no name] 20-Aug-13 5:54am    
What issue? Does "CSDiff.exe" exist on the server at the specified path?
Member 9762654 20-Aug-13 6:02am    
it is installed in my bin in task manager its showing that is its running in background
[no name] 20-Aug-13 6:36am    
Okay... and so? What exactly is the issue?

You can't.
The code will be executed on the server, not the client.
You cannot run programs on the client from server (i.e. C#) code - security prevents that to stop malicious sites from damaging your computer.

Any application the C# code executes will not be even slightly visible to the user. It appears to work in development because the client and server are the same computer - as soon as they become separate PCs, it fails.
 
Share this answer
 
Comments
Member 9762654 20-Aug-13 6:08am    
Thanks for your response is there any other solution to solve this?
OriginalGriff 20-Aug-13 6:53am    
In practice - no.
In theory, yes: you can use an ActiveX control to run the app on the client PC. *BUT* that only works in IE, not in any other browser, and only when ActiveX controls are enabled - which they aren't by default to prevent web sites running applications on user computers... So while you could do it in theory - in practice it would only actually work on 0.001% of computers, and not at all on phones, tablets, MACs, Linux, etc.

You need to look at a different solution!
Let's clarify: do you want this tool to run on client side or on server side?

If you want on client side, than you got your answer from OriginalGriff: you can't in general (first of all not how you intended to do it). Well, you could under special circumstances, but let's not dig into this until you have clarified (for example using Silverlight full trust: http://silverlightedweb.blogspot.hu/2011/12/how-to-get-unrestricted-access-in.html[^]).

If you want this tool to run on server side, than what you have seen that "in task manager its showing that is its running in background" is exactly what it should happen. IIS is a service running under special user account - even if you specify application pool account and you impersonate that account the you will have different session. So your application won't have a GUI visible to anyone :(. This way you should run only executables that have command line interface and no user interaction is needed.
 
Share this answer
 
v2
Comments
Member 9762654 20-Aug-13 6:19am    
i dont want any user interactions to be done actually my exe is to compare two files so before starting process i will provide arguments so it will automatically compare and displays result. and i want my tool to run in server
Zoltán Zörgő 20-Aug-13 6:24am    
Than what's the actual problem? If you see it running in the background and does what it should do, than you have what you need or not? The "will display the results" part is the problematic one: you won't have GUI at all! So it should either exit automatically or you need a command line tool.
Member 9762654 20-Aug-13 6:29am    
i have a button in my tool after clicking that it will display sorry i forgot to mention that
Member 9762654 20-Aug-13 6:26am    
my output file from the tool is not created
Zoltán Zörgő 20-Aug-13 6:30am    
Check if the user running the process has proper rights. Run a procmon and check where fails, or simply run it as the pool user and see for yourself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900