Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Running A Batch file in a windows service

Running A Batch file in a windows service

Scheduled Pinned Locked Moved Visual Basic
csharphtmlhelpquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thedom2
    wrote on last edited by
    #1

    Hi All I am trying to run a batch file in a windows service. It seems to sort of work as I can see a cmd.exe process running when the service executes it but the batch file does not seem to run the contents of the batch. I am using process.start("c:\mybatch.bat") I run the service under my admin account. When I run a similar program in vb.net forms app it works fine. can anyone help or have any suggestions to rectifiy this ? Cheers Dom

    L D 3 Replies Last reply
    0
    • T thedom2

      Hi All I am trying to run a batch file in a windows service. It seems to sort of work as I can see a cmd.exe process running when the service executes it but the batch file does not seem to run the contents of the batch. I am using process.start("c:\mybatch.bat") I run the service under my admin account. When I run a similar program in vb.net forms app it works fine. can anyone help or have any suggestions to rectifiy this ? Cheers Dom

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Try using: System.Diagnostics.process.start("C:\mybatch.bat")

      Caffeination, fuels the programming nation!

      T 1 Reply Last reply
      0
      • L Lost User

        Try using: System.Diagnostics.process.start("C:\mybatch.bat")

        Caffeination, fuels the programming nation!

        T Offline
        T Offline
        thedom2
        wrote on last edited by
        #3

        no dice sadly

        1 Reply Last reply
        0
        • T thedom2

          Hi All I am trying to run a batch file in a windows service. It seems to sort of work as I can see a cmd.exe process running when the service executes it but the batch file does not seem to run the contents of the batch. I am using process.start("c:\mybatch.bat") I run the service under my admin account. When I run a similar program in vb.net forms app it works fine. can anyone help or have any suggestions to rectifiy this ? Cheers Dom

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Try: shell("C:\mybatch.bat")

          T 1 Reply Last reply
          0
          • L Lost User

            Try: shell("C:\mybatch.bat")

            T Offline
            T Offline
            thedom2
            wrote on last edited by
            #5

            thanks ultracoder still no good however i hate/love programming

            1 Reply Last reply
            0
            • T thedom2

              Hi All I am trying to run a batch file in a windows service. It seems to sort of work as I can see a cmd.exe process running when the service executes it but the batch file does not seem to run the contents of the batch. I am using process.start("c:\mybatch.bat") I run the service under my admin account. When I run a similar program in vb.net forms app it works fine. can anyone help or have any suggestions to rectifiy this ? Cheers Dom

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              If your batch file starts an interactive process, it's looking for user input, you'll never see it in the default configuration for a Windows Service. All Windows Services, by default, run under a seperate (non-visible) desktop. In order for a service to be able to interact with the visible desktop, you have to go into the Services manager (Start/Run SERVICES.MSC), find your service, get properties on it, then go to the LogOn tab and enable the "Local System account" login, then enable "Allow service to interact with the desktop".

              Dave Kreskowiak Microsoft MVP - Visual Basic

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups