Re: Starting exe from WebService
From: Don Dumitru [MSFT] (dondu_at_online.microsoft.com)
Date: 07/04/03
- Previous message: Jeffrey Cumpsty: "Match an Identity to an Active Directory Record."
- In reply to: Mazen: "Re: Starting exe from WebService"
- Next in thread: Mazen: "Re: Starting exe from WebService"
- Reply: Mazen: "Re: Starting exe from WebService"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 3 Jul 2003 17:43:12 -0700
Ok, when you said it was WinForm app that you were trying to execute, I
thought that it was intended that the user would then interact with it
through the UI - not have the WinForm app run a batch.
The truth is, services can't run arbitrary programs in a background
WinStation. An arbitrary program (especially a GUI program) can make API
calls to the GUI that will fail, where those API calls would succeed if the
app was running on the desktop. In addition, the context of the registry
can be different (i.e. if the service is running as SYSTEM, but is
impersonating a user, then the user's registry hive may not actually be
loaded, and thus HKEY_CURRENT_USER might not behave like the app expects it
to behave). Those sorts of things apply to "arbitrary programs", and are
just part-and-parcel of how running in the context of a service is different
from running in the context of a normal desktop app.
On the other hand, I personally have had a web method that spawned a
process. In my case, I think I was spawning a command line app (either
wsdl.exe or csc.exe - I forget which), capturing STDOUT from the app, and
returning that in the response from the web method.
So I suspect that it has something to do with the particular app that you
are trying to run, trying to perform operations which are failing in some
way because of the app running in the context of a service.
At this point, if you want to stay on this path, I would suggest that a
better forum would be one of the more Win32-oriented newsgroups (say
microsoft.public.win2000.developer - assuming that is actually an active
group, since I don't hang out there). If it really is the particular app
failing because it is running as a service, then the problem has much less
to do with the .Net Framework, and more to do with Win32. And people with
specific Win32 programming experience may have dealt with similar issues.
--Don
-- This posting is provided "AS IS" with no warranties, and confers no rights. "Mazen" <mazenmanasseh@yahoo.com> wrote in message news:042601c341a5$c24de540$a301280a@phx.gbl... > Thanks for your prompt reply. > > I need to execute the program through the webservice > without necessarily opening its desktop interface. I need > to do that so that when a web client triggers an event, a > webmethod would be called on the server machine to > execute this program on the server which is in turn > expected to perform some tasks. So I just need to execute > it without any further user interaction directly with the > program itself. > I cannot have the program statements coded within the > WebService because the program is complicated and I don't > have access to its source code. Consequently, i am > looking for a way to execute it remotely. > I understand your explanation for a WebService > running as a service; however, I am sure there should be > a solution for this cause I was able to execute it from > the Webservice about a week ago. For some reason I had to > remove IIS and the .Net Framework from the server and > reinstall both of them. After doing that the program > stopped starting from within the WebService. > > Thanks again for any further hints, > > Mazen > > > > > > >-----Original Message----- > >Your web service is probably running as a service on the > machine, and > >services are generally not configured to "interact with > the desktop". So a > >service can't launch an app, and have that app appear on > the desktop of the > >server. > > > >Services run on their own "winstations", in security > contexts which are > >separate from the security context of the user who is > logged in on the > >console of the machine. > > > >In your case, what is probably happening is that the > WinForm app is getting > >launched in the service's winstation, and the WinForm's > initialization is > >failing because it expects a GUI winstation, and the > initial calls to the > >GUI API are failing. > > > >In general, services should not be making API calls that > attempt to interact > >with the desktop. For example, which desktop? With > terminal services, > >there can be multiple people logged in to the machine - > one at the console, > >and several on remote desktops. In this example, if you > were going to > >launch a WinForm, which user's "desktop" would you want > the WinForm to > >appear on? > > > > > >Why do you want a WebMethod to launch a WinForm on the > server? How do you > >envision the user using your application? > > > >-- > >This posting is provided "AS IS" with no warranties, and > confers no rights. > > > > > > > >"Mazen" <mazenmanasseh@yahoo.com> wrote in message > >news:50f001c3417e$74898480$a401280a@phx.gbl... > >> Description: I am trying to run a WinForm application > >> created in C# from a WebMethod by starting a new > process > >> in the Webmethod and performing a Start command on that > >> process. I wonder if the problem described below is > >> related to WebService security priveleges. > >> > >> Problem: When I invoke the WebMethod, the name of the > >> WinForm application instantly appears in the Task > Manager > >> processes list and then very rapidly disappears as if > an > >> error occurs. I have added a Thread.Sleep(10000) in the > >> Form Load event of the application but the name still > >> diappears quickly from the Task Manager without > >> performing what i need it to do. > >> > >> Additional Information: I tried creating another > WinForm > >> application that has the same code as the Webmethod for > >> the process initiation and it worked fine (The > >> application from the process starts and remains listed > in > >> Task Manager). It seems the problem is restricted to > the > >> WebService. Note that I also have changed the > >> machine.config parameters as follows: > >> > >> <identity impersonate=true usrname="" > password=""/> > >> <processmodel ...... username="SYSTEM" ....../> > >> > >> I appreciate any insight on this problem. > >> > >> Thanks > >> > >> Mazen > > > > > >. > >
- Previous message: Jeffrey Cumpsty: "Match an Identity to an Active Directory Record."
- In reply to: Mazen: "Re: Starting exe from WebService"
- Next in thread: Mazen: "Re: Starting exe from WebService"
- Reply: Mazen: "Re: Starting exe from WebService"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|