Windows Service starts Process, but not the application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christiano Donke

    Windows Service starts Process, but not the application

    Hey there...

    Plz...
    I'm writing a Windows Service that will check every x minutes if another
    program is running. If it cannot find the application running, it launches
    it...

    I had already enough trouble with make the timer tick... lol...




    Here's the code that i'm using:

    Dim sPath as String = "c:\project1.ex e"
    Dim iRunning as integer = 0
    Dim p as Process


    For Each p In Process.GetProc esses

    If p.ProcessName.T oString.ToUpper = sProcess.ToUppe r
    Then
    iRunning = -1
    Else
    If iRunning >= 0 Then
    iRunning += 1
    End If
    End If
    Next

    If iRunning >= 0 Then
    'Process.Start( sPath) 'Tried already both of
    these...
    Shell(sPath)
    End if




    Tks in advance,
    Christiano Donke...


  • Herfried K. Wagner [MVP]

    #2
    Re: Windows Service starts Process, but not the application

    "Christiano Donke" <cdonke@digiexp ress.com.brschr ieb:
    I'm writing a Windows Service that will check every x minutes if
    another program is running. If it cannot find the application running, it
    launches it...
    By default Windows services do not have access to the user's desktop. Thus
    the application is started on another desktop.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

    Comment

    • Christiano Donke

      #3
      Re: Windows Service starts Process, but not the application

      Irgh.... :S

      tks a lot...

      Is there any solution for this???
      something like call a batch that runs the program?


      "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atescr eveu na mensagem
      news:Of5$PGgLJH A.5164@TK2MSFTN GP04.phx.gbl...
      "Christiano Donke" <cdonke@digiexp ress.com.brschr ieb:
      > I'm writing a Windows Service that will check every x minutes if
      >another program is running. If it cannot find the application running, it
      >launches it...
      >
      By default Windows services do not have access to the user's desktop.
      Thus the application is started on another desktop.
      >
      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      • Chris Dunaway

        #4
        Re: Windows Service starts Process, but not the application

        On Oct 14, 8:59 am, "Christiano Donke" <cdo...@digiexp ress.com.br>
        wrote:
        Irgh.... :S
        >
        tks a lot...
        >
        Is there any solution for this???
        something like call a batch that runs the program?
        >
        "Herfried K. Wagner [MVP]" <hirf-spam-me-h...@gmx.atescr eveu na mensagemnews:Of 5$PGgLJHA.5164@ TK2MSFTNGP04.ph x.gbl...
        >
        "Christiano Donke" <cdo...@digiexp ress.com.brschr ieb:
        I'm writing a Windows Service that will check every x minutes if
        another program is running. If it cannot find the application running, it
        launches it...
        >
        By default Windows services do not have access to the user's desktop.
        Thus the application is started on another desktop.
        >
        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
        You can right click on your service and in the properties, allow the
        service to interact with the desktop. This is NOT recommended,
        however, and will not work in Windows Vista.

        Why do you need a service to do this? Why not just create a standard
        console application and set it to run when the user logs on (i. e. in
        the Startup folder). Then the app can check for the process you want
        to start.

        Chris

        Comment

        • Patrice

          #5
          Re: Windows Service starts Process, but not the application

          Or even you could perhaps launch the application using the scheduler and
          have the application itself to stop launching if it detects a previous
          instance is already running...

          Most of the time knowing the ultimate goal can help to raise better
          suggestions (depending on what this application is supposed to do, a service
          could be better, does a user needs to do something with it ?)



          --
          Patrice

          "Chris Dunaway" <dunawayc@gmail .coma écrit dans le message de groupe de
          discussion :
          77657a79-ada7-4f40-9e5d-d46f073513b0...leg roups.com...
          On Oct 14, 8:59 am, "Christiano Donke" <cdo...@digiexp ress.com.br>
          wrote:
          >Irgh.... :S
          >>
          >tks a lot...
          >>
          >Is there any solution for this???
          >something like call a batch that runs the program?
          >>
          >"Herfried K. Wagner [MVP]" <hirf-spam-me-h...@gmx.atescr eveu na
          >mensagemnews:O f5$PGgLJHA.5164 @TK2MSFTNGP04.p hx.gbl...
          >>
          "Christiano Donke" <cdo...@digiexp ress.com.brschr ieb:
          > I'm writing a Windows Service that will check every x minutes if
          >another program is running. If it cannot find the application running,
          >it
          >launches it...
          >>
          By default Windows services do not have access to the user's desktop.
          Thus the application is started on another desktop.
          >>
          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
          >
          You can right click on your service and in the properties, allow the
          service to interact with the desktop. This is NOT recommended,
          however, and will not work in Windows Vista.
          >
          Why do you need a service to do this? Why not just create a standard
          console application and set it to run when the user logs on (i. e. in
          the Startup folder). Then the app can check for the process you want
          to start.
          >
          Chris

          Comment

          • Christiano Donke

            #6
            Re: Windows Service starts Process, but not the application


            "Chris Dunaway" <dunawayc@gmail .comescreveu na mensagem
            news:77657a79-ada7-4f40-9e5d-d46f073513b0@8g 2000hse.googleg roups.com...
            On Oct 14, 8:59 am, "Christiano Donke" <cdo...@digiexp ress.com.br>
            wrote:
            >Irgh.... :S
            >>
            >tks a lot...
            >>
            >Is there any solution for this???
            >something like call a batch that runs the program?
            >>
            >"Herfried K. Wagner [MVP]" <hirf-spam-me-h...@gmx.atescr eveu na
            >mensagemnews:O f5$PGgLJHA.5164 @TK2MSFTNGP04.p hx.gbl...
            >>
            "Christiano Donke" <cdo...@digiexp ress.com.brschr ieb:
            > I'm writing a Windows Service that will check every x minutes if
            >another program is running. If it cannot find the application running,
            >it
            >launches it...
            >>
            By default Windows services do not have access to the user's desktop.
            Thus the application is started on another desktop.
            >>
            --
            M S Herfried K. Wagner
            M V P <URL:http://dotnet.mvps.org/>
            V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
            >
            You can right click on your service and in the properties, allow the
            service to interact with the desktop. This is NOT recommended,
            however, and will not work in Windows Vista.
            >
            Why do you need a service to do this? Why not just create a standard
            console application and set it to run when the user logs on (i. e. in
            the Startup folder). Then the app can check for the process you want
            to start.
            >
            Chris

            Chris,

            this service will check if another program is running.. The app that is
            being check connects tha local database with the remote db, "trading"
            infomration...
            This app must always be running... but sometimes it crashes or some dumb
            user closes it...

            that's why i need this service... Otherwise, it's gonna be closed too..
            lol...


            I'll figure out how to install the service as local system service (and
            not as local user), with parameters and then i'll post the results...

            Christiano.


            Comment

            • Christiano Donke

              #7
              Re: Windows Service starts Process, but not the application

              I'm writing this as an service, because the user CAN'T do anything to it...

              it must check it a specific app is running (every 10 minutes). If not,
              launches it, else sleep.


              "Patrice" <http://www.chez.com/scribe/escreveu na mensagem
              news:05EC0AFE-5052-4BAD-BE8B-CE346D2B5962@mi crosoft.com...
              Or even you could perhaps launch the application using the scheduler and
              have the application itself to stop launching if it detects a previous
              instance is already running...
              >
              Most of the time knowing the ultimate goal can help to raise better
              suggestions (depending on what this application is supposed to do, a
              service could be better, does a user needs to do something with it ?)
              >
              >
              >
              --
              Patrice
              >
              "Chris Dunaway" <dunawayc@gmail .coma écrit dans le message de groupe de
              discussion :
              77657a79-ada7-4f40-9e5d-d46f073513b0...leg roups.com...
              >On Oct 14, 8:59 am, "Christiano Donke" <cdo...@digiexp ress.com.br>
              >wrote:
              >>Irgh.... :S
              >>>
              >>tks a lot...
              >>>
              >>Is there any solution for this???
              >>something like call a batch that runs the program?
              >>>
              >>"Herfried K. Wagner [MVP]" <hirf-spam-me-h...@gmx.atescr eveu na
              >>mensagemnews: Of5$PGgLJHA.516 4@TK2MSFTNGP04. phx.gbl...
              >>>
              >"Christiano Donke" <cdo...@digiexp ress.com.brschr ieb:
              >> I'm writing a Windows Service that will check every x minutes if
              >>another program is running. If it cannot find the application
              >>running, it
              >>launches it...
              >>>
              >By default Windows services do not have access to the user's desktop.
              >Thus the application is started on another desktop.
              >>>
              >--
              >M S Herfried K. Wagner
              >M V P <URL:http://dotnet.mvps.org/>
              >V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
              >>
              >You can right click on your service and in the properties, allow the
              >service to interact with the desktop. This is NOT recommended,
              >however, and will not work in Windows Vista.
              >>
              >Why do you need a service to do this? Why not just create a standard
              >console application and set it to run when the user logs on (i. e. in
              >the Startup folder). Then the app can check for the process you want
              >to start.
              >>
              >Chris
              >
              >

              Comment

              Working...