Results 1 to 10 of 10

Thread: Windows scheduler: Running a batch file as another user?

  1. #1
    Andrew Hodgson Guest

    Windows scheduler: Running a batch file as another user?

    Hi,

    I have an account which is in the users and IIS_WPG group. I would
    like this account to run a batch file every hour, however, when I
    schedule the script to run when I am logged in as an account with
    administrator privileges to run under that user, and when I start the
    job, it fails. I can see from the audit log that the user is being
    logged in and out, but it doesn't start. I attempted to run the
    scheduler logged in as the account I wanted the script to run under,
    however, it does not give me access.

    So my question is: What are the minimum permissions I need to grant in
    order to let this script run as a scheduled job under the limited
    account?

    Thanks.
    Andrew.

  2. #2
    Pegasus \(MVP\) Guest

    Re: Windows scheduler: Running a batch file as another user?


    "Andrew Hodgson" <me3@privacy.net> wrote in message
    news:2bf0t3ti8glcacqg48ve0dvbijtolkufcf@news.giganews.com...
    > Hi,
    >
    > I have an account which is in the users and IIS_WPG group. I would
    > like this account to run a batch file every hour, however, when I
    > schedule the script to run when I am logged in as an account with
    > administrator privileges to run under that user, and when I start the
    > job, it fails. I can see from the audit log that the user is being
    > logged in and out, but it doesn't start. I attempted to run the
    > scheduler logged in as the account I wanted the script to run under,
    > however, it does not give me access.
    >
    > So my question is: What are the minimum permissions I need to grant in
    > order to let this script run as a scheduled job under the limited
    > account?
    >
    > Thanks.
    > Andrew.


    Just because you cannot see the result from your scheduled
    job does not mean that it did not run. Try coding it like this:

    @echo off
    echo %date% %time% %UserName% >> c:\test.log
    "c:\tools\YourCommand.exe" 1>>c:\test.log 2>>&1

    Not schedule this batch file, then check out c:\test.log.
    Make sure the account you use for the scheduled job
    has a non-blank password.



  3. #3
    JohnB Guest

    Re: Windows scheduler: Running a batch file as another user?

    I don't have anything to add to your answer but, I have a general question
    on your batch file.

    I've redirected the results of a DOS command to a text file before, and I
    always used this symbol: ">"
    But you have a double >
    I tested it and get the same results with both. Why 2?

    And, what does this command do: >>c:\test.log 2>>&1

    I can see that it's again redirecting the output to test.log, but what I
    don't understand is what follows test.log (2>>&1)

    Always looking to learn something new ;-)





    "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
    news:OvhcoS8fIHA.4140@TK2MSFTNGP04.phx.gbl...
    >
    > "Andrew Hodgson" <me3@privacy.net> wrote in message
    > news:2bf0t3ti8glcacqg48ve0dvbijtolkufcf@news.giganews.com...
    >> Hi,
    >>
    >> I have an account which is in the users and IIS_WPG group. I would
    >> like this account to run a batch file every hour, however, when I
    >> schedule the script to run when I am logged in as an account with
    >> administrator privileges to run under that user, and when I start the
    >> job, it fails. I can see from the audit log that the user is being
    >> logged in and out, but it doesn't start. I attempted to run the
    >> scheduler logged in as the account I wanted the script to run under,
    >> however, it does not give me access.
    >>
    >> So my question is: What are the minimum permissions I need to grant in
    >> order to let this script run as a scheduled job under the limited
    >> account?
    >>
    >> Thanks.
    >> Andrew.

    >
    > Just because you cannot see the result from your scheduled
    > job does not mean that it did not run. Try coding it like this:
    >
    > @echo off
    > echo %date% %time% %UserName% >> c:\test.log
    > "c:\tools\YourCommand.exe" 1>>c:\test.log 2>>&1
    >
    > Not schedule this batch file, then check out c:\test.log.
    > Make sure the account you use for the scheduled job
    > has a non-blank password.
    >




  4. #4
    Pegasus \(MVP\) Guest

    Re: Windows scheduler: Running a batch file as another user?

    Good questions! The command
    echo %date% > c:\test.txt
    will write the current date into c:\test.txt.

    The command
    echo %time% >> c:\test.txt
    will ***add*** the current time to whatever
    is already in c:\test.txt.

    The command
    xcopy.exe /.. /.. /.. .. .. 1>c:\test.log 2>c:\test.err
    will write the ***standard*** output from the xcopy
    command into c:\test.log and the ***error*** output
    (if any) into c:\test.err. If you want both outputs in
    c:\test.log then you have to code it like so:
    xcopy.exe /.. /.. /.. .. .. 1>c:\test.log 2>&1

    I cannot tell you if and where this might be documented.


    "JohnB" <jbrigan@yahoo.com> wrote in message
    news:eKHFai8fIHA.3940@TK2MSFTNGP05.phx.gbl...
    >I don't have anything to add to your answer but, I have a general question
    >on your batch file.
    >
    > I've redirected the results of a DOS command to a text file before, and I
    > always used this symbol: ">"
    > But you have a double >
    > I tested it and get the same results with both. Why 2?
    >
    > And, what does this command do: >>c:\test.log 2>>&1
    >
    > I can see that it's again redirecting the output to test.log, but what I
    > don't understand is what follows test.log (2>>&1)
    >
    > Always looking to learn something new ;-)
    >
    >
    >
    >
    >
    > "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
    > news:OvhcoS8fIHA.4140@TK2MSFTNGP04.phx.gbl...
    >>
    >> "Andrew Hodgson" <me3@privacy.net> wrote in message
    >> news:2bf0t3ti8glcacqg48ve0dvbijtolkufcf@news.giganews.com...
    >>> Hi,
    >>>
    >>> I have an account which is in the users and IIS_WPG group. I would
    >>> like this account to run a batch file every hour, however, when I
    >>> schedule the script to run when I am logged in as an account with
    >>> administrator privileges to run under that user, and when I start the
    >>> job, it fails. I can see from the audit log that the user is being
    >>> logged in and out, but it doesn't start. I attempted to run the
    >>> scheduler logged in as the account I wanted the script to run under,
    >>> however, it does not give me access.
    >>>
    >>> So my question is: What are the minimum permissions I need to grant in
    >>> order to let this script run as a scheduled job under the limited
    >>> account?
    >>>
    >>> Thanks.
    >>> Andrew.

    >>
    >> Just because you cannot see the result from your scheduled
    >> job does not mean that it did not run. Try coding it like this:
    >>
    >> @echo off
    >> echo %date% %time% %UserName% >> c:\test.log
    >> "c:\tools\YourCommand.exe" 1>>c:\test.log 2>>&1
    >>
    >> Not schedule this batch file, then check out c:\test.log.
    >> Make sure the account you use for the scheduled job
    >> has a non-blank password.
    >>

    >
    >




  5. #5
    JohnB Guest

    Re: Windows scheduler: Running a batch file as another user?

    I've been in IT since DOS 3.1 days and I don't ever remember seeing anything
    about redirecting the error output, so I will have to make a note of that
    one.... because I sure won't use it often enough to remember it :) Good
    stuff!!


    "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
    news:%23Z7Dmv8fIHA.3352@TK2MSFTNGP04.phx.gbl...
    > Good questions! The command
    > echo %date% > c:\test.txt
    > will write the current date into c:\test.txt.
    >
    > The command
    > echo %time% >> c:\test.txt
    > will ***add*** the current time to whatever
    > is already in c:\test.txt.
    >
    > The command
    > xcopy.exe /.. /.. /.. .. .. 1>c:\test.log 2>c:\test.err
    > will write the ***standard*** output from the xcopy
    > command into c:\test.log and the ***error*** output
    > (if any) into c:\test.err. If you want both outputs in
    > c:\test.log then you have to code it like so:
    > xcopy.exe /.. /.. /.. .. .. 1>c:\test.log 2>&1
    >
    > I cannot tell you if and where this might be documented.
    >
    >
    > "JohnB" <jbrigan@yahoo.com> wrote in message
    > news:eKHFai8fIHA.3940@TK2MSFTNGP05.phx.gbl...
    >>I don't have anything to add to your answer but, I have a general question
    >>on your batch file.
    >>
    >> I've redirected the results of a DOS command to a text file before, and I
    >> always used this symbol: ">"
    >> But you have a double >
    >> I tested it and get the same results with both. Why 2?
    >>
    >> And, what does this command do: >>c:\test.log 2>>&1
    >>
    >> I can see that it's again redirecting the output to test.log, but what I
    >> don't understand is what follows test.log (2>>&1)
    >>
    >> Always looking to learn something new ;-)
    >>
    >>
    >>
    >>
    >>
    >> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
    >> news:OvhcoS8fIHA.4140@TK2MSFTNGP04.phx.gbl...
    >>>
    >>> "Andrew Hodgson" <me3@privacy.net> wrote in message
    >>> news:2bf0t3ti8glcacqg48ve0dvbijtolkufcf@news.giganews.com...
    >>>> Hi,
    >>>>
    >>>> I have an account which is in the users and IIS_WPG group. I would
    >>>> like this account to run a batch file every hour, however, when I
    >>>> schedule the script to run when I am logged in as an account with
    >>>> administrator privileges to run under that user, and when I start the
    >>>> job, it fails. I can see from the audit log that the user is being
    >>>> logged in and out, but it doesn't start. I attempted to run the
    >>>> scheduler logged in as the account I wanted the script to run under,
    >>>> however, it does not give me access.
    >>>>
    >>>> So my question is: What are the minimum permissions I need to grant in
    >>>> order to let this script run as a scheduled job under the limited
    >>>> account?
    >>>>
    >>>> Thanks.
    >>>> Andrew.
    >>>
    >>> Just because you cannot see the result from your scheduled
    >>> job does not mean that it did not run. Try coding it like this:
    >>>
    >>> @echo off
    >>> echo %date% %time% %UserName% >> c:\test.log
    >>> "c:\tools\YourCommand.exe" 1>>c:\test.log 2>>&1
    >>>
    >>> Not schedule this batch file, then check out c:\test.log.
    >>> Make sure the account you use for the scheduled job
    >>> has a non-blank password.
    >>>

    >>
    >>

    >
    >




  6. #6
    Andrew Hodgson Guest

    Re: Windows scheduler: Running a batch file as another user?

    On Thu, 6 Mar 2008 16:41:16 -0500, "JohnB" <jbrigan@yahoo.com> wrote:

    >I've been in IT since DOS 3.1 days and I don't ever remember seeing anything
    >about redirecting the error output, so I will have to make a note of that
    >one.... because I sure won't use it often enough to remember it :) Good
    >stuff!!


    I have always used this in Unix, didn't realise either it worked in
    Windows though.

    Thanks.
    Andrew.

  7. #7
    Andrew Hodgson Guest

    Re: Windows scheduler: Running a batch file as another user?

    On Thu, 6 Mar 2008 20:59:54 +0100, "Pegasus \(MVP\)"
    <I.can@fly.com.oz> wrote:

    >
    >"Andrew Hodgson" <me3@privacy.net> wrote in message
    >news:2bf0t3ti8glcacqg48ve0dvbijtolkufcf@news.giganews.com...
    >> Hi,
    >>
    >> I have an account which is in the users and IIS_WPG group. I would
    >> like this account to run a batch file every hour, however, when I
    >> schedule the script to run when I am logged in as an account with
    >> administrator privileges to run under that user, and when I start the
    >> job, it fails. I can see from the audit log that the user is being
    >> logged in and out, but it doesn't start. I attempted to run the
    >> scheduler logged in as the account I wanted the script to run under,
    >> however, it does not give me access.
    >>
    >> So my question is: What are the minimum permissions I need to grant in
    >> order to let this script run as a scheduled job under the limited
    >> account?
    >>
    >> Thanks.
    >> Andrew.

    >
    >Just because you cannot see the result from your scheduled
    >job does not mean that it did not run. Try coding it like this:


    Actually in the scheduled task window it said it did not run, and the
    batch file does create a log which did not get populated.

    We can run it fine if the account it is in the administrators group.
    The user has full rights to the relevant directories - including the
    log files directory.

    Thanks.
    Andrew.

  8. #8
    Pegasus \(MVP\) Guest

    Re: Windows scheduler: Running a batch file as another user?


    "Andrew Hodgson" <me3@privacy.net> wrote in message
    news:me86t31b0mq42d5jeolg71gkoq7p5jqshh@news.giganews.com...
    > On Thu, 6 Mar 2008 20:59:54 +0100, "Pegasus \(MVP\)"
    > <I.can@fly.com.oz> wrote:
    >
    >>
    >>"Andrew Hodgson" <me3@privacy.net> wrote in message
    >>news:2bf0t3ti8glcacqg48ve0dvbijtolkufcf@news.giganews.com...
    >>> Hi,
    >>>
    >>> I have an account which is in the users and IIS_WPG group. I would
    >>> like this account to run a batch file every hour, however, when I
    >>> schedule the script to run when I am logged in as an account with
    >>> administrator privileges to run under that user, and when I start the
    >>> job, it fails. I can see from the audit log that the user is being
    >>> logged in and out, but it doesn't start. I attempted to run the
    >>> scheduler logged in as the account I wanted the script to run under,
    >>> however, it does not give me access.
    >>>
    >>> So my question is: What are the minimum permissions I need to grant in
    >>> order to let this script run as a scheduled job under the limited
    >>> account?
    >>>
    >>> Thanks.
    >>> Andrew.

    >>
    >>Just because you cannot see the result from your scheduled
    >>job does not mean that it did not run. Try coding it like this:

    >
    > Actually in the scheduled task window it said it did not run, and the
    > batch file does create a log which did not get populated.
    >
    > We can run it fine if the account it is in the administrators group.
    > The user has full rights to the relevant directories - including the
    > log files directory.
    >
    > Thanks.
    > Andrew.


    You must give the user a non-blank password and you must
    set your group policy so that this user can log on as a batch job.



  9. #9
    Andrew Hodgson Guest

    Re: Windows scheduler: Running a batch file as another user?

    On Sun, 9 Mar 2008 00:49:28 +0100, "Pegasus \(MVP\)"
    <I.can@fly.com.oz> wrote:

    >You must give the user a non-blank password and you must
    >set your group policy so that this user can log on as a batch job.


    The batch job may be the issue, thanks for that.

    Andrew.

  10. #10
    Bruce Sanderson Guest

    Re: Windows scheduler: Running a batch file as another user?

    See
    http://technet2.microsoft.com/window....mspx?mfr=true
    and
    http://technet2.microsoft.com/window....mspx?mfr=true

    Keep in mind that the Command Prompt in Windows 2000 and later is not an
    emulated DOS environment; it's a native Windows 2000 (or later) command
    interpreter window.
    --
    Bruce Sanderson
    http://members.shaw.ca/bsanders

    It is perfectly useless to know the right answer to the wrong question.



    "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
    news:%23Z7Dmv8fIHA.3352@TK2MSFTNGP04.phx.gbl...
    > Good questions! The command
    > echo %date% > c:\test.txt
    > will write the current date into c:\test.txt.
    >
    > The command
    > echo %time% >> c:\test.txt
    > will ***add*** the current time to whatever
    > is already in c:\test.txt.
    >
    > The command
    > xcopy.exe /.. /.. /.. .. .. 1>c:\test.log 2>c:\test.err
    > will write the ***standard*** output from the xcopy
    > command into c:\test.log and the ***error*** output
    > (if any) into c:\test.err. If you want both outputs in
    > c:\test.log then you have to code it like so:
    > xcopy.exe /.. /.. /.. .. .. 1>c:\test.log 2>&1
    >
    > I cannot tell you if and where this might be documented.
    >
    >
    > "JohnB" <jbrigan@yahoo.com> wrote in message
    > news:eKHFai8fIHA.3940@TK2MSFTNGP05.phx.gbl...
    >>I don't have anything to add to your answer but, I have a general question
    >>on your batch file.
    >>
    >> I've redirected the results of a DOS command to a text file before, and I
    >> always used this symbol: ">"
    >> But you have a double >
    >> I tested it and get the same results with both. Why 2?
    >>
    >> And, what does this command do: >>c:\test.log 2>>&1
    >>
    >> I can see that it's again redirecting the output to test.log, but what I
    >> don't understand is what follows test.log (2>>&1)
    >>
    >> Always looking to learn something new ;-)
    >>
    >>
    >>
    >>
    >>
    >> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
    >> news:OvhcoS8fIHA.4140@TK2MSFTNGP04.phx.gbl...
    >>>
    >>> "Andrew Hodgson" <me3@privacy.net> wrote in message
    >>> news:2bf0t3ti8glcacqg48ve0dvbijtolkufcf@news.giganews.com...
    >>>> Hi,
    >>>>
    >>>> I have an account which is in the users and IIS_WPG group. I would
    >>>> like this account to run a batch file every hour, however, when I
    >>>> schedule the script to run when I am logged in as an account with
    >>>> administrator privileges to run under that user, and when I start the
    >>>> job, it fails. I can see from the audit log that the user is being
    >>>> logged in and out, but it doesn't start. I attempted to run the
    >>>> scheduler logged in as the account I wanted the script to run under,
    >>>> however, it does not give me access.
    >>>>
    >>>> So my question is: What are the minimum permissions I need to grant in
    >>>> order to let this script run as a scheduled job under the limited
    >>>> account?
    >>>>
    >>>> Thanks.
    >>>> Andrew.
    >>>
    >>> Just because you cannot see the result from your scheduled
    >>> job does not mean that it did not run. Try coding it like this:
    >>>
    >>> @echo off
    >>> echo %date% %time% %UserName% >> c:\test.log
    >>> "c:\tools\YourCommand.exe" 1>>c:\test.log 2>>&1
    >>>
    >>> Not schedule this batch file, then check out c:\test.log.
    >>> Make sure the account you use for the scheduled job
    >>> has a non-blank password.
    >>>

    >>
    >>

    >
    >



Similar Threads

  1. FTP Upload batch file doesn't work properly in Task Scheduler
    By supphavith09 in forum Windows Server Help
    Replies: 1
    Last Post: 09-02-2012, 07:39 AM
  2. Need batch file to delete user files in Windows XP
    By mcamp32 in forum Windows XP Support
    Replies: 1
    Last Post: 26-05-2011, 10:54 PM
  3. Shutdown window after running batch file
    By Jaiwanti in forum Operating Systems
    Replies: 4
    Last Post: 13-12-2010, 06:25 PM
  4. VBscript to run batch file carry on running
    By hokaday in forum Software Development
    Replies: 1
    Last Post: 12-02-2010, 01:34 AM
  5. Running a batch file from another?
    By Linn Kubler in forum Windows Server Help
    Replies: 2
    Last Post: 28-02-2008, 09:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,043,206.97303 seconds with 16 queries