Announcement

Collapse
No announcement yet.

remote scheduled tasks

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • remote scheduled tasks

    Hi all,

    I would like to run a scheduled tasks from a user PC to a server (Stdt 2003 sp1) with a normal user account. (by normal i mean without admin or power user rights).

    run command :
    schtasks /run /S mywindowsserver /TN mytesttasks

    My testuser is owner of the .job and has full control on it.
    I've added him in the tasks folder too.

    See cacls result :

    C:\cacls.exe c:\windows\tasks
    c:\windows\Tasks CREATOR OWNEROI)(CI)(IO)F
    BUILTIN\Backup Operatorsspecial access
    READ_CONTROL
    SYNCHRONIZE
    FILE_GENERIC_READ
    FILE_GENERIC_EXECUTE
    FILE_READ_DATA
    FILE_WRITE_DATA
    FILE_READ_EA
    FILE_EXECUTE
    FILE_READ_ATTRIBUTES

    <Account Domain not found>(special access
    READ_CONTROL
    SYNCHRONIZE
    FILE_GENERIC_READ
    FILE_GENERIC_EXECUTE
    FILE_READ_DATA
    FILE_WRITE_DATA
    FILE_READ_EA
    FILE_EXECUTE
    FILE_READ_ATTRIBUTES

    BUILTIN\AdministratorsOI)(CI)F
    NT AUTHORITY\SYSTEMOI)(CI)F
    mydomain\my testuserOI)(CI)F
    The testuser has the "log on as a btach job" too.

    When i run the command line, i have an access denied.

    Help please
    Last edited by hasou; 20th November 2007, 16:03. Reason: typo

  • #2
    Re: remote scheduled tasks

    You could opt out of using the schtasks command and script the scheduled task

    Note that scripting scheduled tasks requires the tasks executable/script to be present in the location specified

    The following is a vb script. Copy and paste the text into a text file with an extention of .vbs

    <-------------------------code start (dont copy this line)------------------------------------>

    'Check if job already exists
    If objFSO.FileExists("c:\windows\tasks\test.job") Then wscript.quit(1)

    'Create Calculator Job
    strComputer = "." 'Put server name here (leaving it as "." runs against local machine)
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
    JobID = "Calc"
    name = "Calc"
    Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
    errJobCreate = objNewJob.Create _
    ("c:\calc.exe", "********080000.000000+540", True , 1, , True, name)

    <-------------------------code end (dont copy this line)------------------------------------>
    Explanation:
    The one line that you need to really worry about is the last one, which I'll break down for you as best I can

    The c:\calc.exe is the path to the scheduled executable
    The ********080000.000000+540 is the time that the task will run, in UTC time. This is of the form YYYYMMDDHHMMSS.MMMMMM(+-)OOO, where YYYYMMDD must be replaced by ********. Example: ********083000.000000+540, which implies 8:30 A.M. Western australian daylight savings time (+8GMT)

    The +540 is calculated by getting the hours ahead of GMT and multiplying it by 60. If daylight savings is in effect, add 60 to this

    So I am in Perth, which is +8GMT. Therefore 8*60 = 480. With DST in effect, it makes it 540

    I go on holidays to Hawaii which is -10GMT. Therefore -10*60 = -600. If DST was in effect, it would make it -540

    The rest of the syntax can be pretty well ignored; except for the 1 This corresponds to the day of the week that the task will run

    1 - Monday

    2 - Tuesday

    4 - Wednesday

    8 - Thursday

    16 - Friday

    32 - Saturday

    64 - Sunday

    To run the task on multiple days, use a logical OR to combine values. For example, to run a task on Tuesday, Thursday, and Saturday, use the following code:

    ("c:\calc.exe", "********080000.000000+540", True , 2 OR 8 OR 32, , True, name)

    The "True" Values mean that this task will run repeatedly
    If you set this to "False" It will run once and end on the specified day

    let me know if this helps

    Comment


    • #3
      Re: remote scheduled tasks

      Note that jobs created via this script run as SYSTEM and not a specified user

      Comment


      • #4
        Re: remote scheduled tasks

        Thanks for your reply, i'm checking if it's helpfull

        Comment


        • #5
          Re: remote scheduled tasks

          Hi,

          I tested your script but it's not working.

          The scheduled job must run within a storage admin account, not server system.

          Comment


          • #6
            Re: remote scheduled tasks

            Does anyone know how to permit a user to view the Scheduled tasks share on a server pls ?

            By default only Administrators can.

            Thanks,

            Comment


            • #7
              Re: remote scheduled tasks

              Sorry, I left my check in there for a local, not remote computer task

              'Create Calculator Job
              strComputer = "servername"

              Set objWMIService = GetObject("winmgmts:" _
              & "{impersonationLevel=impersonate}!\\" _
              & strComputer & "\root\cimv2")
              JobID = "Calc"
              name = "Calc"
              Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
              errJobCreate = objNewJob.Create _
              ("c:\calc.exe", "********080000.000000+540", True , 1, , True, name)

              This should work

              Following the second half of your request, by default scheduled tasks are shared on a server. The windows directory is also shared by a hidden share of $admin. By default, "Authenticated users" have read and execute permissions to this share. To let users 'see' this folder, you have to assign them a permission of 'modify'
              Last edited by Robbo; 23rd November 2007, 02:53.

              Comment

              Working...
              X