Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Bat file will not run in Windows Schedule Tasks

Windows Server Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 03-06-2008
Member
 
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

Reply With Quote
  #2  
Old 04-06-2008
Pegasus \(MVP\)
 
Posts: n/a
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.


Reply With Quote
  #3  
Old 04-06-2008
Member
 
Join Date: Jun 2008
Posts: 2
That was it. Really appreciate your response.

Thanks,
Doo4fun
Reply With Quote
  #4  
Old 04-06-2008
Pegasus \(MVP\)
 
Posts: n/a
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.


Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Bat file will not run in Windows Schedule Tasks"
Thread Thread Starter Forum Replies Last Post
Windows Scheduled Tasks don't luanch if tasks not finished Andy Candy Windows Software 3 21-08-2009 11:47 AM
XP Schedule Batch file Stockholm Windows Software 3 03-01-2009 09:36 AM
How to schedule tasks run at specified time via group policy? Deabelos Active Directory 1 14-08-2008 12:30 PM
Using Windows "scheduled tasks" to launch a .bat file Ascetica Windows Security 1 19-02-2008 11:03 AM
Schedule tasks Last Result 0x2 HAYES Window 2000 Help 1 28-02-2005 11:43 PM


All times are GMT +5.5. The time now is 09:39 PM.