Solved

I want to start myapplication.exe from a web form using System.Diagnostics.Process.Start

Posted on 2007-11-30
13
436 Views
Last Modified: 2013-12-14
I want to start a Windows application from a Web form both written in Visual Studio 2005. The Win app displays a crystal report. I am using the System.Diagnostics.Process to start the win app and it works fine in my box but when I deploy it to the server (uwdevsvr1) I don't get anything. When I run the web app from my box and set the UNC path for the StartInfo.FileName to the Win app path in uwdevsvr1it works ok but the application won't start if I deploy the web form to the server. I have set security to allow Everybody full control on the directory where both the Web form and the Win app are. I've given uwdevsvr1\asp.net full administration rights. I've tried Try/Catch/Finally on the process.Start() and it does go through the finally with no errors. Anyone have any ideas how I may find what's wrong?
Dim proc As New Process

 

    With proc

       '.StartInfo.FileName = "E:\AgencyProfileReport\AgencyLiaisonsReports.application"

        .StartInfo.Domain = "UWHOUSTON"

        .StartInfo.UseShellExecute = True

        .StartInfo.WorkingDirectory = "file:///E:\AgencyProfileReport"

 

        Try

            .Start()

        Catch ex As Exception

            LogMessage(ex.Message.ToString)

        Finally

            LogMessage("Everything should be ok")

        End Try

    End With

Open in new window

0
Comment
Question by:Yves Mellet
  • 6
  • 5
  • 2
13 Comments
 
LVL 2

Expert Comment

by:yossi_intlock
ID: 20386086
when you try to start the proccess from the web application that does not reside on the same machine with the web server itself( i guess you probably push a submit button that sends a post back  to your web server), the application does not throw an exception coz it does succeed in runing the proccess BUT not on the local machine though it run this proccess on your (remote)  web server.  - try to write an event each time the win app runs on the web server and youll probably see that every requst from a remote client initiates the proccess on the web server. you cannot start a local service using this method. to solve that problem you have to call this  winApp localy on the client. to be able  to do that.a common method is to use an ActiveX control installed on the client  (like the way microsoft check updates for a windows licenced machine using WindowsUpdate that as you might knowruns on a web page). another way is to create your own com or com+ dll that can initiate the winapp ,install it on every machine and call it with javascript on the client.  
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 20393034
does your application run headless, no GUI at all?
If not, it cannot be run from within a web server.
0
 

Author Comment

by:Yves Mellet
ID: 20404927
Sorry for not replying sooner. I've been sick and yesterday and today I am resting so I am not by my computer at work. Answer for ahoffmann is: I am running a crystal report viewer in a windows form. That is my win app. But I've tried with Notepad.exe instead to see if my app is the problem and it is all the same. Yossi's answer requires making sure we're on the same page.  I am a little confuse with the words "web server". When you say web server I think of it as running IIS on any machine. Both, my own box and  the remote server (uwdevsvr1) contain IIS with a virtual directory from where I run my web app.  Having said that I should point out that both applications Win and Web are supposed to run on the same boxes (or web servers). Either on mine (localhost) or on the  remote (uwdevsvr1). When the web app runs from the remote server and I ckick the button to run the win app (which is in uwdevsvr1 also) it does not work. It only works when I run the web app from my box (localhost) and it also works if I call the win app that resides on uwdevsvr1. I have not tried to run the win app from a web form in another remote web server. I just have run it from my own box where I have full rights.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 20405379
> .. in a windows form
what are/is "windows form"?

> .. it does not work.
As I said: you cannot run a GUI (windows program) from within the web server (though, it may work if both, the web server and the app to be started are on the same host --most likely localhost-- and the path to the app is defined correctly)
0
 

Author Comment

by:Yves Mellet
ID: 20406060
a windows form is actually my compiled win app consisting of a form and a crystal viewer on it.But it can be any other win app like notepad. I say it doesn't work because the application wether it is notepad or myapp.exe does not start and I get no error messages from try catch variable ex as exception as specified by my code above. The win app is supposed to run in a separate process just as if you would have started it yourself by double clicking it or typing it in the run command. This works if my web app is running on my box but the moment I run it from uwdevsvr1 no win app starts.
0
 
LVL 2

Expert Comment

by:yossi_intlock
ID: 20415362
have you tried to impersonate ? it seems like the problem is you dont have execute permissions on local folders. try to add <identity impersonate="true" /> to your web.config. if it doesnt work add a local machine  user userName and password to the identity. if it still dont work try to change the anonymouse user in IIS to a user with more rights. and if it still dont work - replace the user in the appPool (thats the user who runs the proccess ) and grant it execute permission on your local folders.
hope this will help..
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Yves Mellet
ID: 20416329
I have not tried to impersonate but I gave uwdevsvr1\ASP.NET Administrative rights. Also the directories where both apps reside I have given full control to user Everyone. One would think that I'd get an error message if I needed rights. In any case I worked with my network administrator on security and he said this cannot be about security since we've given all we can to these apps. I may just have to create this report as a stand alone application and not being called from the web app. I have spent too much time on this and I don't want you all to keep brainstorming on this issue if it's going no where. Thank you both for your quick resposes and suggestions but I will delete this question first thing next week if I don't hear anything else.
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 20418863
> .. can be any other win app like notepad.
you cannot start an application with an GUI from within the web server. Dot. Period.
0
 

Author Comment

by:Yves Mellet
ID: 20421232
If I run my web app from my box (http://localhost/mywebapp/default.aspx) and click the button "Run Report" then it brings up the mywinapp.exe in a separate window, that is as a separate process:- whcih is what I want.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 20423595
how often should we tell you that this works on your localhost only?
0
 

Author Comment

by:Yves Mellet
ID: 20623765
I have run apps in clasic ASP using: Response.Write "  RunApp(""" & strAppCmdLine & """)" where strAppCmdLine = "\\uwsys01\AgencyMaintenance\AgencyInfo.exe" and both the web and exe applications reside on uwsys01. I can't accept ahoffmann statement. In fact this is the way I finally did it. I will close this question.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 20626553
> Response.Write "  RunApp(  ...
hmm, I'm not used to  ASP, but this sounds like it writes to the client which then starts the application from the UNC path --> the application runs on the client!
This is different to what you asked for : application should run on server.
0
 

Author Closing Comment

by:Yves Mellet
ID: 31412028
It's been so long now I had to jump on to other pressing  things. I am sure I could have worked around a better solution to start .net exe from a web server app but your answer is accurate.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now