[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 486
  • Last Modified:

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

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
Yves Mellet
Asked:
Yves Mellet
  • 6
  • 5
  • 2
1 Solution
 
yossi_intlockCommented:
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
 
ahoffmannCommented:
does your application run headless, no GUI at all?
If not, it cannot be run from within a web server.
0
 
Yves MelletAuthor Commented:
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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
ahoffmannCommented:
> .. 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
 
Yves MelletAuthor Commented:
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
 
yossi_intlockCommented:
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
 
Yves MelletAuthor Commented:
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
 
ahoffmannCommented:
> .. can be any other win app like notepad.
you cannot start an application with an GUI from within the web server. Dot. Period.
0
 
Yves MelletAuthor Commented:
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
 
ahoffmannCommented:
how often should we tell you that this works on your localhost only?
0
 
Yves MelletAuthor Commented:
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
 
ahoffmannCommented:
> 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
 
Yves MelletAuthor Commented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now