Results 1 to 8 of 8

Thread: Problems running batch file as scheduled task

  1. #1
    pete0085 Guest

    Problems running batch file as scheduled task

    I have been trying to run a batch file as a scheduled task. Everytime I
    select to "run now" it doesn't work or preform the task. If I manually
    double click the batch file, then it runs. Is there some command I need to
    add to allow this to run?

  2. #2
    Pegasus \(MVP\) Guest

    Re: Problems running batch file as scheduled task

    You need to add the usual diagnostic stuff, e.g. like so:
    @echo off
    echo %date% %time% %UserName% >> c:\test.txt
    net use >> c:\test.txt
    s: 1>>c:\test.txt 2>>&1
    cd s:\shared\admin\quality.loop 1>>c:\test.txt 2>>&1
    FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I del *.txt 1>>c:\test.txt
    2>>&1

    The second line serves to prove that the batch file does run, regardless of
    what you might think.

    Now examine c:\test.txt and you will probably see that drive S: does not
    exist or is inaccessible. This is not surprising - mapped drives exist only
    within the context of the process that creates them. You should use UNC
    coding for scheduled tasks.


    "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    news:4662C23E-8840-4710-99D4-A315AB93B132@microsoft.com...
    > The task is being run by the domain administrator credentials. I've tried
    > to
    > also include the full path to the file.
    >
    > This is the batch file.
    >
    > s:
    > cd s:\shared\admin\quality.loop
    > FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I
    > del *.txt
    >
    > As mentioned earlier in runs fine manually.
    >
    > It's running the 7z-zip program in the batch file to zip a file with a
    > password.
    > "pete0085" wrote:
    >
    >> I have been trying to run a batch file as a scheduled task. Everytime I
    >> select to "run now" it doesn't work or preform the task. If I manually
    >> double click the batch file, then it runs. Is there some command I need
    >> to
    >> add to allow this to run?




  3. #3
    pete0085 Guest

    Re: Problems running batch file as scheduled task

    The problem I was having with the UNC name was the batch file does not allow
    me to enter cd \\server1\shared\admin. Is there a way around this?

    I can enter the drive letter from the server, which is E or cd
    e:\shared\admin, but the scheduled task does not run correctly and ends with
    a code of 1 or never stops running and I need to end it myself.

    "Pegasus (MVP)" wrote:

    > You need to add the usual diagnostic stuff, e.g. like so:
    > @echo off
    > echo %date% %time% %UserName% >> c:\test.txt
    > net use >> c:\test.txt
    > s: 1>>c:\test.txt 2>>&1
    > cd s:\shared\admin\quality.loop 1>>c:\test.txt 2>>&1
    > FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I del *.txt 1>>c:\test.txt
    > 2>>&1
    >
    > The second line serves to prove that the batch file does run, regardless of
    > what you might think.
    >
    > Now examine c:\test.txt and you will probably see that drive S: does not
    > exist or is inaccessible. This is not surprising - mapped drives exist only
    > within the context of the process that creates them. You should use UNC
    > coding for scheduled tasks.
    >
    >
    > "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    > news:4662C23E-8840-4710-99D4-A315AB93B132@microsoft.com...
    > > The task is being run by the domain administrator credentials. I've tried
    > > to
    > > also include the full path to the file.
    > >
    > > This is the batch file.
    > >
    > > s:
    > > cd s:\shared\admin\quality.loop
    > > FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I
    > > del *.txt
    > >
    > > As mentioned earlier in runs fine manually.
    > >
    > > It's running the 7z-zip program in the batch file to zip a file with a
    > > password.
    > > "pete0085" wrote:
    > >
    > >> I have been trying to run a batch file as a scheduled task. Everytime I
    > >> select to "run now" it doesn't work or preform the task. If I manually
    > >> double click the batch file, then it runs. Is there some command I need
    > >> to
    > >> add to allow this to run?

    >
    >
    >


  4. #4
    Pegasus \(MVP\) Guest

    Re: Problems running batch file as scheduled task

    It's not the batch file that won't allow you the CD command on a UNC path -
    this is a property of UNC paths that applies everywhere, even at the Command
    Prompt. You can get around it quite easily, e.g. like so:

    @echo off
    echo %date% %time% %UserName% >> c:\test.txt
    set WD=\\Server\Shared\Admin\quality.loop
    FOR /F %%I IN ('dir /b %WD%\*.txt') DO echo 7z a %WD%\%%~nI.zip -pcomp2009
    %WD%\%%I
    echo del %WD%\*.txt

    Remove the word "echo" in Lines 3 and 4 to activate the batch file.


    "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    news:E09C5DF6-20BC-46C1-9643-F9878F64CACE@microsoft.com...
    > The problem I was having with the UNC name was the batch file does not
    > allow
    > me to enter cd \\server1\shared\admin. Is there a way around this?
    >
    > I can enter the drive letter from the server, which is E or cd
    > e:\shared\admin, but the scheduled task does not run correctly and ends
    > with
    > a code of 1 or never stops running and I need to end it myself.
    >
    > "Pegasus (MVP)" wrote:
    >
    >> You need to add the usual diagnostic stuff, e.g. like so:
    >> @echo off
    >> echo %date% %time% %UserName% >> c:\test.txt
    >> net use >> c:\test.txt
    >> s: 1>>c:\test.txt 2>>&1
    >> cd s:\shared\admin\quality.loop 1>>c:\test.txt 2>>&1
    >> FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I del *.txt
    >> 1>>c:\test.txt
    >> 2>>&1
    >>
    >> The second line serves to prove that the batch file does run, regardless
    >> of
    >> what you might think.
    >>
    >> Now examine c:\test.txt and you will probably see that drive S: does not
    >> exist or is inaccessible. This is not surprising - mapped drives exist
    >> only
    >> within the context of the process that creates them. You should use UNC
    >> coding for scheduled tasks.
    >>
    >>
    >> "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    >> news:4662C23E-8840-4710-99D4-A315AB93B132@microsoft.com...
    >> > The task is being run by the domain administrator credentials. I've
    >> > tried
    >> > to
    >> > also include the full path to the file.
    >> >
    >> > This is the batch file.
    >> >
    >> > s:
    >> > cd s:\shared\admin\quality.loop
    >> > FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I
    >> > del *.txt
    >> >
    >> > As mentioned earlier in runs fine manually.
    >> >
    >> > It's running the 7z-zip program in the batch file to zip a file with a
    >> > password.
    >> > "pete0085" wrote:
    >> >
    >> >> I have been trying to run a batch file as a scheduled task. Everytime
    >> >> I
    >> >> select to "run now" it doesn't work or preform the task. If I
    >> >> manually
    >> >> double click the batch file, then it runs. Is there some command I
    >> >> need
    >> >> to
    >> >> add to allow this to run?

    >>
    >>
    >>




  5. #5
    pete0085 Guest

    Re: Problems running batch file as scheduled task

    I thank you for your help, but nothing seems to be working. The file will
    run manually . I'm thinking it has to do with the program that is being run,
    7z-zip, that's the 7z command in the batch file. I don't know if that makes
    a difference or gives you other ideas.

    "Pegasus (MVP)" wrote:

    > It's not the batch file that won't allow you the CD command on a UNC path -
    > this is a property of UNC paths that applies everywhere, even at the Command
    > Prompt. You can get around it quite easily, e.g. like so:
    >
    > @echo off
    > echo %date% %time% %UserName% >> c:\test.txt
    > set WD=\\Server\Shared\Admin\quality.loop
    > FOR /F %%I IN ('dir /b %WD%\*.txt') DO echo 7z a %WD%\%%~nI.zip -pcomp2009
    > %WD%\%%I
    > echo del %WD%\*.txt
    >
    > Remove the word "echo" in Lines 3 and 4 to activate the batch file.
    >
    >
    > "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    > news:E09C5DF6-20BC-46C1-9643-F9878F64CACE@microsoft.com...
    > > The problem I was having with the UNC name was the batch file does not
    > > allow
    > > me to enter cd \\server1\shared\admin. Is there a way around this?
    > >
    > > I can enter the drive letter from the server, which is E or cd
    > > e:\shared\admin, but the scheduled task does not run correctly and ends
    > > with
    > > a code of 1 or never stops running and I need to end it myself.
    > >
    > > "Pegasus (MVP)" wrote:
    > >
    > >> You need to add the usual diagnostic stuff, e.g. like so:
    > >> @echo off
    > >> echo %date% %time% %UserName% >> c:\test.txt
    > >> net use >> c:\test.txt
    > >> s: 1>>c:\test.txt 2>>&1
    > >> cd s:\shared\admin\quality.loop 1>>c:\test.txt 2>>&1
    > >> FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I del *.txt
    > >> 1>>c:\test.txt
    > >> 2>>&1
    > >>
    > >> The second line serves to prove that the batch file does run, regardless
    > >> of
    > >> what you might think.
    > >>
    > >> Now examine c:\test.txt and you will probably see that drive S: does not
    > >> exist or is inaccessible. This is not surprising - mapped drives exist
    > >> only
    > >> within the context of the process that creates them. You should use UNC
    > >> coding for scheduled tasks.
    > >>
    > >>
    > >> "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    > >> news:4662C23E-8840-4710-99D4-A315AB93B132@microsoft.com...
    > >> > The task is being run by the domain administrator credentials. I've
    > >> > tried
    > >> > to
    > >> > also include the full path to the file.
    > >> >
    > >> > This is the batch file.
    > >> >
    > >> > s:
    > >> > cd s:\shared\admin\quality.loop
    > >> > FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I
    > >> > del *.txt
    > >> >
    > >> > As mentioned earlier in runs fine manually.
    > >> >
    > >> > It's running the 7z-zip program in the batch file to zip a file with a
    > >> > password.
    > >> > "pete0085" wrote:
    > >> >
    > >> >> I have been trying to run a batch file as a scheduled task. Everytime
    > >> >> I
    > >> >> select to "run now" it doesn't work or preform the task. If I
    > >> >> manually
    > >> >> double click the batch file, then it runs. Is there some command I
    > >> >> need
    > >> >> to
    > >> >> add to allow this to run?
    > >>
    > >>
    > >>

    >
    >
    >


  6. #6
    Pegasus \(MVP\) Guest

    Re: Problems running batch file as scheduled task

    Why don't you restore the debugging code I gave you in my first reply? You
    will probably find that the batch file can't locate 7z.exe, for the very
    simple reason that you did not state where it is located. To make your batch
    file robust you must always fully qualify your third-party commands, e.g.
    like so:
    c:\MyTools\7z.exe
    If you don't then your batch files will fail, for perfectly obvious reasons.


    "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    news:107489B4-492B-4CCD-AD8C-E54315057F20@microsoft.com...
    >I thank you for your help, but nothing seems to be working. The file will
    > run manually . I'm thinking it has to do with the program that is being
    > run,
    > 7z-zip, that's the 7z command in the batch file. I don't know if that
    > makes
    > a difference or gives you other ideas.
    >
    > "Pegasus (MVP)" wrote:
    >
    >> It's not the batch file that won't allow you the CD command on a UNC
    >> path -
    >> this is a property of UNC paths that applies everywhere, even at the
    >> Command
    >> Prompt. You can get around it quite easily, e.g. like so:
    >>
    >> @echo off
    >> echo %date% %time% %UserName% >> c:\test.txt
    >> set WD=\\Server\Shared\Admin\quality.loop
    >> FOR /F %%I IN ('dir /b %WD%\*.txt') DO echo 7z a
    >> %WD%\%%~nI.zip -pcomp2009
    >> %WD%\%%I
    >> echo del %WD%\*.txt
    >>
    >> Remove the word "echo" in Lines 3 and 4 to activate the batch file.
    >>
    >>
    >> "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    >> news:E09C5DF6-20BC-46C1-9643-F9878F64CACE@microsoft.com...
    >> > The problem I was having with the UNC name was the batch file does not
    >> > allow
    >> > me to enter cd \\server1\shared\admin. Is there a way around this?
    >> >
    >> > I can enter the drive letter from the server, which is E or cd
    >> > e:\shared\admin, but the scheduled task does not run correctly and ends
    >> > with
    >> > a code of 1 or never stops running and I need to end it myself.
    >> >
    >> > "Pegasus (MVP)" wrote:
    >> >
    >> >> You need to add the usual diagnostic stuff, e.g. like so:
    >> >> @echo off
    >> >> echo %date% %time% %UserName% >> c:\test.txt
    >> >> net use >> c:\test.txt
    >> >> s: 1>>c:\test.txt 2>>&1
    >> >> cd s:\shared\admin\quality.loop 1>>c:\test.txt 2>>&1
    >> >> FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I del *.txt
    >> >> 1>>c:\test.txt
    >> >> 2>>&1
    >> >>
    >> >> The second line serves to prove that the batch file does run,
    >> >> regardless
    >> >> of
    >> >> what you might think.
    >> >>
    >> >> Now examine c:\test.txt and you will probably see that drive S: does
    >> >> not
    >> >> exist or is inaccessible. This is not surprising - mapped drives exist
    >> >> only
    >> >> within the context of the process that creates them. You should use
    >> >> UNC
    >> >> coding for scheduled tasks.
    >> >>
    >> >>
    >> >> "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    >> >> news:4662C23E-8840-4710-99D4-A315AB93B132@microsoft.com...
    >> >> > The task is being run by the domain administrator credentials. I've
    >> >> > tried
    >> >> > to
    >> >> > also include the full path to the file.
    >> >> >
    >> >> > This is the batch file.
    >> >> >
    >> >> > s:
    >> >> > cd s:\shared\admin\quality.loop
    >> >> > FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I
    >> >> > del *.txt
    >> >> >
    >> >> > As mentioned earlier in runs fine manually.
    >> >> >
    >> >> > It's running the 7z-zip program in the batch file to zip a file with
    >> >> > a
    >> >> > password.
    >> >> > "pete0085" wrote:
    >> >> >
    >> >> >> I have been trying to run a batch file as a scheduled task.
    >> >> >> Everytime
    >> >> >> I
    >> >> >> select to "run now" it doesn't work or preform the task. If I
    >> >> >> manually
    >> >> >> double click the batch file, then it runs. Is there some command I
    >> >> >> need
    >> >> >> to
    >> >> >> add to allow this to run?
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>




  7. #7
    pete0085 Guest

    Re: Problems running batch file as scheduled task

    It seems to be working correctly now. After some tweaking I noticed it was
    deleting the .txt files but not converting it to a zip file which made me
    believe there was a problem with the 7z program. I actually had the
    incorrect 7z.exe in the directory. It needed to be the command line version
    of the 7z.exe. It was more an error on my part. Still didn't make any sense
    why it would run by clicking the file, but it works now and thanks for your
    help. I learned something new with the Set WD command.

    "Pegasus (MVP)" wrote:

    > Why don't you restore the debugging code I gave you in my first reply? You
    > will probably find that the batch file can't locate 7z.exe, for the very
    > simple reason that you did not state where it is located. To make your batch
    > file robust you must always fully qualify your third-party commands, e.g.
    > like so:
    > c:\MyTools\7z.exe
    > If you don't then your batch files will fail, for perfectly obvious reasons.
    >
    >
    > "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    > news:107489B4-492B-4CCD-AD8C-E54315057F20@microsoft.com...
    > >I thank you for your help, but nothing seems to be working. The file will
    > > run manually . I'm thinking it has to do with the program that is being
    > > run,
    > > 7z-zip, that's the 7z command in the batch file. I don't know if that
    > > makes
    > > a difference or gives you other ideas.
    > >
    > > "Pegasus (MVP)" wrote:
    > >
    > >> It's not the batch file that won't allow you the CD command on a UNC
    > >> path -
    > >> this is a property of UNC paths that applies everywhere, even at the
    > >> Command
    > >> Prompt. You can get around it quite easily, e.g. like so:
    > >>
    > >> @echo off
    > >> echo %date% %time% %UserName% >> c:\test.txt
    > >> set WD=\\Server\Shared\Admin\quality.loop
    > >> FOR /F %%I IN ('dir /b %WD%\*.txt') DO echo 7z a
    > >> %WD%\%%~nI.zip -pcomp2009
    > >> %WD%\%%I
    > >> echo del %WD%\*.txt
    > >>
    > >> Remove the word "echo" in Lines 3 and 4 to activate the batch file.
    > >>
    > >>
    > >> "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    > >> news:E09C5DF6-20BC-46C1-9643-F9878F64CACE@microsoft.com...
    > >> > The problem I was having with the UNC name was the batch file does not
    > >> > allow
    > >> > me to enter cd \\server1\shared\admin. Is there a way around this?
    > >> >
    > >> > I can enter the drive letter from the server, which is E or cd
    > >> > e:\shared\admin, but the scheduled task does not run correctly and ends
    > >> > with
    > >> > a code of 1 or never stops running and I need to end it myself.
    > >> >
    > >> > "Pegasus (MVP)" wrote:
    > >> >
    > >> >> You need to add the usual diagnostic stuff, e.g. like so:
    > >> >> @echo off
    > >> >> echo %date% %time% %UserName% >> c:\test.txt
    > >> >> net use >> c:\test.txt
    > >> >> s: 1>>c:\test.txt 2>>&1
    > >> >> cd s:\shared\admin\quality.loop 1>>c:\test.txt 2>>&1
    > >> >> FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I del *.txt
    > >> >> 1>>c:\test.txt
    > >> >> 2>>&1
    > >> >>
    > >> >> The second line serves to prove that the batch file does run,
    > >> >> regardless
    > >> >> of
    > >> >> what you might think.
    > >> >>
    > >> >> Now examine c:\test.txt and you will probably see that drive S: does
    > >> >> not
    > >> >> exist or is inaccessible. This is not surprising - mapped drives exist
    > >> >> only
    > >> >> within the context of the process that creates them. You should use
    > >> >> UNC
    > >> >> coding for scheduled tasks.
    > >> >>
    > >> >>
    > >> >> "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    > >> >> news:4662C23E-8840-4710-99D4-A315AB93B132@microsoft.com...
    > >> >> > The task is being run by the domain administrator credentials. I've
    > >> >> > tried
    > >> >> > to
    > >> >> > also include the full path to the file.
    > >> >> >
    > >> >> > This is the batch file.
    > >> >> >
    > >> >> > s:
    > >> >> > cd s:\shared\admin\quality.loop
    > >> >> > FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I
    > >> >> > del *.txt
    > >> >> >
    > >> >> > As mentioned earlier in runs fine manually.
    > >> >> >
    > >> >> > It's running the 7z-zip program in the batch file to zip a file with
    > >> >> > a
    > >> >> > password.
    > >> >> > "pete0085" wrote:
    > >> >> >
    > >> >> >> I have been trying to run a batch file as a scheduled task.
    > >> >> >> Everytime
    > >> >> >> I
    > >> >> >> select to "run now" it doesn't work or preform the task. If I
    > >> >> >> manually
    > >> >> >> double click the batch file, then it runs. Is there some command I
    > >> >> >> need
    > >> >> >> to
    > >> >> >> add to allow this to run?
    > >> >>
    > >> >>
    > >> >>
    > >>
    > >>
    > >>

    >
    >
    >


  8. #8
    Pegasus \(MVP\) Guest

    Re: Problems running batch file as scheduled task

    Thanks for the feedback. There is probably a slight misunderstanding in your
    reply. The "set WD" command has no particular effect other then creating an
    environmental variable called "WD" so that I don't have to retype it several
    times in my batch file. I might just as easily have made it "set
    x1=\\Server\Shared\Admin\quality.loop".

    "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    news:A114CE83-C910-4707-8C7C-B185BD738FEC@microsoft.com...
    > It seems to be working correctly now. After some tweaking I noticed it
    > was
    > deleting the .txt files but not converting it to a zip file which made me
    > believe there was a problem with the 7z program. I actually had the
    > incorrect 7z.exe in the directory. It needed to be the command line
    > version
    > of the 7z.exe. It was more an error on my part. Still didn't make any
    > sense
    > why it would run by clicking the file, but it works now and thanks for
    > your
    > help. I learned something new with the Set WD command.
    >
    > "Pegasus (MVP)" wrote:
    >
    >> Why don't you restore the debugging code I gave you in my first reply?
    >> You
    >> will probably find that the batch file can't locate 7z.exe, for the very
    >> simple reason that you did not state where it is located. To make your
    >> batch
    >> file robust you must always fully qualify your third-party commands, e.g.
    >> like so:
    >> c:\MyTools\7z.exe
    >> If you don't then your batch files will fail, for perfectly obvious
    >> reasons.
    >>
    >>
    >> "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    >> news:107489B4-492B-4CCD-AD8C-E54315057F20@microsoft.com...
    >> >I thank you for your help, but nothing seems to be working. The file
    >> >will
    >> > run manually . I'm thinking it has to do with the program that is
    >> > being
    >> > run,
    >> > 7z-zip, that's the 7z command in the batch file. I don't know if that
    >> > makes
    >> > a difference or gives you other ideas.
    >> >
    >> > "Pegasus (MVP)" wrote:
    >> >
    >> >> It's not the batch file that won't allow you the CD command on a UNC
    >> >> path -
    >> >> this is a property of UNC paths that applies everywhere, even at the
    >> >> Command
    >> >> Prompt. You can get around it quite easily, e.g. like so:
    >> >>
    >> >> @echo off
    >> >> echo %date% %time% %UserName% >> c:\test.txt
    >> >> set WD=\\Server\Shared\Admin\quality.loop
    >> >> FOR /F %%I IN ('dir /b %WD%\*.txt') DO echo 7z a
    >> >> %WD%\%%~nI.zip -pcomp2009
    >> >> %WD%\%%I
    >> >> echo del %WD%\*.txt
    >> >>
    >> >> Remove the word "echo" in Lines 3 and 4 to activate the batch file.
    >> >>
    >> >>
    >> >> "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    >> >> news:E09C5DF6-20BC-46C1-9643-F9878F64CACE@microsoft.com...
    >> >> > The problem I was having with the UNC name was the batch file does
    >> >> > not
    >> >> > allow
    >> >> > me to enter cd \\server1\shared\admin. Is there a way around this?
    >> >> >
    >> >> > I can enter the drive letter from the server, which is E or cd
    >> >> > e:\shared\admin, but the scheduled task does not run correctly and
    >> >> > ends
    >> >> > with
    >> >> > a code of 1 or never stops running and I need to end it myself.
    >> >> >
    >> >> > "Pegasus (MVP)" wrote:
    >> >> >
    >> >> >> You need to add the usual diagnostic stuff, e.g. like so:
    >> >> >> @echo off
    >> >> >> echo %date% %time% %UserName% >> c:\test.txt
    >> >> >> net use >> c:\test.txt
    >> >> >> s: 1>>c:\test.txt 2>>&1
    >> >> >> cd s:\shared\admin\quality.loop 1>>c:\test.txt 2>>&1
    >> >> >> FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I del *.txt
    >> >> >> 1>>c:\test.txt
    >> >> >> 2>>&1
    >> >> >>
    >> >> >> The second line serves to prove that the batch file does run,
    >> >> >> regardless
    >> >> >> of
    >> >> >> what you might think.
    >> >> >>
    >> >> >> Now examine c:\test.txt and you will probably see that drive S:
    >> >> >> does
    >> >> >> not
    >> >> >> exist or is inaccessible. This is not surprising - mapped drives
    >> >> >> exist
    >> >> >> only
    >> >> >> within the context of the process that creates them. You should use
    >> >> >> UNC
    >> >> >> coding for scheduled tasks.
    >> >> >>
    >> >> >>
    >> >> >> "pete0085" <pete0085@discussions.microsoft.com> wrote in message
    >> >> >> news:4662C23E-8840-4710-99D4-A315AB93B132@microsoft.com...
    >> >> >> > The task is being run by the domain administrator credentials.
    >> >> >> > I've
    >> >> >> > tried
    >> >> >> > to
    >> >> >> > also include the full path to the file.
    >> >> >> >
    >> >> >> > This is the batch file.
    >> >> >> >
    >> >> >> > s:
    >> >> >> > cd s:\shared\admin\quality.loop
    >> >> >> > FOR %%I IN (*.txt) DO 7z a %%~nI.zip -pcomp2009 %%I
    >> >> >> > del *.txt
    >> >> >> >
    >> >> >> > As mentioned earlier in runs fine manually.
    >> >> >> >
    >> >> >> > It's running the 7z-zip program in the batch file to zip a file
    >> >> >> > with
    >> >> >> > a
    >> >> >> > password.
    >> >> >> > "pete0085" wrote:
    >> >> >> >
    >> >> >> >> I have been trying to run a batch file as a scheduled task.
    >> >> >> >> Everytime
    >> >> >> >> I
    >> >> >> >> select to "run now" it doesn't work or preform the task. If I
    >> >> >> >> manually
    >> >> >> >> double click the batch file, then it runs. Is there some
    >> >> >> >> command I
    >> >> >> >> need
    >> >> >> >> to
    >> >> >> >> add to allow this to run?
    >> >> >>
    >> >> >>
    >> >> >>
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>




Similar Threads

  1. Windows 7 scheduled task running hidden. Why?
    By Rasawer in forum Operating Systems
    Replies: 3
    Last Post: 13-12-2010, 12:34 AM
  2. XCOPY command in bat file doesn't run as scheduled task
    By Laurense in forum Operating Systems
    Replies: 4
    Last Post: 29-03-2010, 06:02 PM
  3. Task Schedule batch file
    By donator in forum Vista Help
    Replies: 6
    Last Post: 15-02-2010, 06:48 PM
  4. scheduled printing of a text file using batch files or schtasks
    By Gadgetman in forum Windows XP Support
    Replies: 10
    Last Post: 12-06-2008, 11:48 PM
  5. How to run a scheduled task via a batch job
    By akkha1234@gmail.com in forum Windows Server Help
    Replies: 3
    Last Post: 18-05-2007, 06:35 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,715,245,414.54968 seconds with 17 queries