Results 1 to 4 of 4

Thread: Bat file will not run in Windows Schedule Tasks

  1. #1
    Join Date
    Jun 2008
    Posts
    2

    Bat file will not run in Windows Schedule Tasks

    Batch file runs at cmd.exe but exits with 0x1 when attempting to run in Schdueled tasks.
    My intent is to delete all files with the .bak extention in Z:\ (this is a network share that is mapped on the local server) then copy the most recent .bak file to that directory

    In Schedule tasks the Run = c:\WINDOWS\System32\cmd.exe /c D:\Copy2Share\FileCopy.bat

    @ECHO OFF
    rem This script Deletes all *.bak files
    rem then Copies most recent .bak file to directory

    set localdir=O:\SQL-Backup\
    set destdir=Z:\

    del /s "%destdir%*.bak"

    for /f "delims=" %%a in ('dir "%localdir%*.bak" /b /od') do set "file=%%a"
    copy "%localdir%%file%" "%destdir%" >nul

    Your assistance is appreciated.
    Doo4fun

  2. #2
    Pegasus \(MVP\) Guest

    Re: Bat file will not run in Windows Schedule Tasks


    "Doo4fun" <Doo4fun.3ag1fd@DoNotSpam.com> wrote in message
    news:Doo4fun.3ag1fd@DoNotSpam.com...
    >
    > Batch file runs at cmd.exe but exits with 0x1 when attempting to run in
    > Schdueled tasks.
    > My intent is to delete all files with the .bak extention in Z:\ (this
    > is a network share that is mapped on the local server) then copy the
    > most recent .bak file to that directory
    >
    > In Schedule tasks the Run = c:\WINDOWS\System32\cmd.exe /c
    > D:\Copy2Share\FileCopy.bat
    >
    > @ECHO OFF
    > rem This script Deletes all *.bak files
    > rem then Copies most recent .bak file to directory
    >
    > set localdir=O:\SQL-Backup\
    > set destdir=Z:\
    >
    > del /s "%destdir%*.bak"
    >
    > for /f "delims=" %%a in ('dir "%localdir%*.bak" /b /od') do set
    > "file=%%a"
    > copy "%localdir%%file%" "%destdir%" >nul
    >
    > Your assistance is appreciated.
    > Doo4fun
    >
    >
    > --
    > Doo4fun


    Don't use fixed share drive letters in scheduled tasks - it won't
    work properly. Use UNC coding instead.



  3. #3
    Join Date
    Jun 2008
    Posts
    2
    That was it. Really appreciate your response.

    Thanks,
    Doo4fun

  4. #4
    Pegasus \(MVP\) Guest

    Re: Bat file will not run in Windows Schedule Tasks


    "Doo4fun" <Doo4fun.3ahnrd@DoNotSpam.com> wrote in message
    news:Doo4fun.3ahnrd@DoNotSpam.com...
    >
    > That was it. Really appreciate your response.
    >
    > Thanks,
    > Doo4fun
    >


    Thanks for the feedback.



Similar Threads

  1. Windows Scheduled Tasks don't luanch if tasks not finished
    By Andy Candy in forum Windows Software
    Replies: 3
    Last Post: 21-08-2009, 11:47 AM
  2. XP Schedule Batch file
    By Stockholm in forum Windows Software
    Replies: 3
    Last Post: 03-01-2009, 09:36 AM
  3. Replies: 1
    Last Post: 14-08-2008, 12:30 PM
  4. Using Windows "scheduled tasks" to launch a .bat file
    By Ascetica in forum Windows Security
    Replies: 1
    Last Post: 19-02-2008, 11:03 AM
  5. Schedule tasks Last Result 0x2
    By HAYES in forum Window 2000 Help
    Replies: 1
    Last Post: 28-02-2005, 11:43 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,711,693,699.94955 seconds with 16 queries