Re: Starting exe from WebService

From: Don Dumitru [MSFT] (dondu_at_online.microsoft.com)
Date: 07/04/03

  • Next message: Liu Guidong: "How can I export a certificate by programming?"
    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
    > >
    > >
    > >.
    > >
    

  • Next message: Liu Guidong: "How can I&#12288;export a certificate by programming?"

    Relevant Pages

    • Re: Starting exe from WebService
      ... >through the UI - not have the WinForm app run a batch. ... >> I need to execute the program through the webservice ... >> WebService because the program is complicated and I ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: Relationship between Application.Exit() and AppDomain
      ... Yes, the app we are writing is being coded in Winform, it's not a Web ... trying to create an app that would host some other applications, either GUI ... AppDomain to host the 3rd party code for security/robustness reason? ...
      (microsoft.public.dotnet.framework.clr)
    • Re: Winform vs Webform: how to choose?
      ... installling /desinstalling automatica when you no use bat always when you ... > new application becomes a Winform vs a Webform application. ... > that every app should be, by default, a Winform app unless it positively ... Visual Studio could never be a Webform app because it requires ...
      (microsoft.public.dotnet.languages.vb)
    • RE: 2.0 DataSources vs. TableAdapter/Datasets
      ... components in winform application and asp.net application, ... application is desktop app where all the class instances and componets live ... | There are articles on the new TableAdapters where it says that a key new ... | common datasources for the whole project (accessed via the Data menu ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: auto mouse click
      ... like i said i'm using a winform to create this program. ... > wanted to create a windows app that would play a web-based slot machine game ... > app to play this web-based free slot machine game. ...
      (microsoft.public.dotnet.languages.vb)