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 console application as the System user via Scheduled Tasks [Windows 2008]

Running a console application as the System user via Scheduled Tasks [Windows 2008]

Scheduled Pinned Locked Moved Visual Basic
helpcsharpsysadmindebugging
5 Posts 2 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.
  • S Offline
    S Offline
    svanwass
    wrote on last edited by
    #1

    I have written a console app in VB.net. Basically it reads some information from a couple Excel files, takes the information contained within and goes to that device on our network to poll for more information. This information is then dumped into a new different Excel file. I am able to run the application via debug and all works great. I can also run it manually via .exe and all works great. The problem comes in when i attempt to create a scheduled task (every hour) to run as the System user. My error logging shows that it is not able to access the Excel files (which previously worked when run as admin). I have tried to troubleshoot by specifically setting the file permissions for that folder/file for the System user. Could someone shed any light on why I am running into this problem? Thanks! -Steve

    G 2 Replies Last reply
    0
    • S svanwass

      I have written a console app in VB.net. Basically it reads some information from a couple Excel files, takes the information contained within and goes to that device on our network to poll for more information. This information is then dumped into a new different Excel file. I am able to run the application via debug and all works great. I can also run it manually via .exe and all works great. The problem comes in when i attempt to create a scheduled task (every hour) to run as the System user. My error logging shows that it is not able to access the Excel files (which previously worked when run as admin). I have tried to troubleshoot by specifically setting the file permissions for that folder/file for the System user. Could someone shed any light on why I am running into this problem? Thanks! -Steve

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      a lot of errors like this are caused by account issues - the scheduler usually runs as a particular account - with no standard user environment - so try to fully specify paths etc to the files. Depending on the o/s, you could change the scheduler to use a particular account's credentials - this may throw other scheduled apps out, especially if they require desktop/gui access The other thing I do is use a 'runas' type program to impersonate the user, including load the registry hive etc, so that the environment is correct - the [in this case 'Excel manipulation program'] is then running under a real user not a limited system account {ps : I use tqcrunas from a company called 'Quimeras' - Im not affiliated with them in any way, but its a great product that allows me to encrypt/protect credentials/command sets - they are really good at support btw} 'g'

      S 1 Reply Last reply
      0
      • S svanwass

        I have written a console app in VB.net. Basically it reads some information from a couple Excel files, takes the information contained within and goes to that device on our network to poll for more information. This information is then dumped into a new different Excel file. I am able to run the application via debug and all works great. I can also run it manually via .exe and all works great. The problem comes in when i attempt to create a scheduled task (every hour) to run as the System user. My error logging shows that it is not able to access the Excel files (which previously worked when run as admin). I have tried to troubleshoot by specifically setting the file permissions for that folder/file for the System user. Could someone shed any light on why I am running into this problem? Thanks! -Steve

        G Offline
        G Offline
        Garth J Lancaster
        wrote on last edited by
        #3

        in addition to the tqcrunas product [just to prove Im not biased], Wingnut software also make such a product http://www.wingnutsoftware.com/[^] see 'Encrypted runas' 'g'

        modified on Sunday, December 27, 2009 9:21 PM

        1 Reply Last reply
        0
        • G Garth J Lancaster

          a lot of errors like this are caused by account issues - the scheduler usually runs as a particular account - with no standard user environment - so try to fully specify paths etc to the files. Depending on the o/s, you could change the scheduler to use a particular account's credentials - this may throw other scheduled apps out, especially if they require desktop/gui access The other thing I do is use a 'runas' type program to impersonate the user, including load the registry hive etc, so that the environment is correct - the [in this case 'Excel manipulation program'] is then running under a real user not a limited system account {ps : I use tqcrunas from a company called 'Quimeras' - Im not affiliated with them in any way, but its a great product that allows me to encrypt/protect credentials/command sets - they are really good at support btw} 'g'

          S Offline
          S Offline
          svanwass
          wrote on last edited by
          #4

          1. All file paths are absolute. 2. The scheduler for 2008 needs the System account to run scheduled tasks without being logged in as far as I have been able to tell. I have a scheduled task to download a weather map every 10 minutes and would only run using the System account. 3. I attempted to use runas via the command line for the System user however, the password was prompted for, which is not known.

          G 1 Reply Last reply
          0
          • S svanwass

            1. All file paths are absolute. 2. The scheduler for 2008 needs the System account to run scheduled tasks without being logged in as far as I have been able to tell. I have a scheduled task to download a weather map every 10 minutes and would only run using the System account. 3. I attempted to use runas via the command line for the System user however, the password was prompted for, which is not known.

            G Offline
            G Offline
            Garth J Lancaster
            wrote on last edited by
            #5

            reply to 3. yep, thats the issue with the standard runas - there are some programs Ive seen that allow you to pass a password to runas Can you create a seperate user account and test the excel bit under that - if you can use 'runas' and your user account to run the excel bit, then you can use one of the other [encrypted] runas tools I suggest to finish the automation I still think its your system account vs COM components that EXCEL might be using thats giving you the issue - Ive had the same issue on Windows 2003 server 'g'

            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