Guest JohnB Posted July 2, 2008 Posted July 2, 2008 Re: Another batch file question Well it worked when I ran it live. But it didn't work when I ran it in Scheduled Tasks. And I can not figure out why. I copied the beginning of the batch file below. It copies about 10 folders, only 1 is shown there. It seemed to have failed at the very beginning. There was no folder with the current date. It never got created. Which would explain why the rest of it failed. So I created a test batch file that only creates the folder. Ran it in scheduled tasks, and wouldn't you know, it worked fine. Any ideas? I'm totaly stumped on this one. TIA "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message news:u7NWRc32IHA.1204@TK2MSFTNGP04.phx.gbl... > Thanks for the feedback. @Echo off REM REM Copy files from MainServer to TeraServer REM Set variable to current date set MyDate=%date:~4,2%%date:~7,2%%date:~-2% REM Create a subfolder with today's date as the name MD t:\%MyDate% REM Backup folder: Folder1 echo Started backup of Folder1 at %time%, %date% > BackupLog.txt xcopy /s /e /i /q /y d:\Folder1 "t:\%MyDate%\Folder1" >> BackupLog.txt echo Finished Folder1 at %time%, %date% >> BackupLog.txt echo. >> BackupLog.txt
Guest Pegasus \(MVP\) Posted July 2, 2008 Posted July 2, 2008 Re: Another batch file question Re: Another batch file question Drive T: is probably a mapped share. If it is then it would not exist under the Task Scheduler session - why should it? You should use UNC coding for all scheduled tasks. Furthermore, when debugging scheduled tasks then it is helpful to give yourself some eyes, e.g. like so: @echo off echo %date% %time% %UserName% > c:\test.txt net use >> c:\test.txt dir T:\ >> c:\test.txt xcopy /s /e /i /q /y d:\Folder1 "t:\%MyDate%\Folder1" 1>> c:\test.txt 2>>&1 The contents of c:\test.txt should put an end to you having to grope blindly for an explanation. "JohnB" <jbrigan@yahoo.com> wrote in message news:Ohor5GE3IHA.5024@TK2MSFTNGP03.phx.gbl... > Well it worked when I ran it live. But it didn't work when I ran it in > Scheduled Tasks. And I can not figure out why. I copied the beginning of > the batch file below. It copies about 10 folders, only 1 is shown there. > > It seemed to have failed at the very beginning. There was no folder with > the current date. It never got created. Which would explain why the rest > of it failed. So I created a test batch file that only creates the > folder. Ran it in scheduled tasks, and wouldn't you know, it worked fine. > > Any ideas? > I'm totaly stumped on this one. > > TIA > > > > "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message > news:u7NWRc32IHA.1204@TK2MSFTNGP04.phx.gbl... >> Thanks for the feedback. > > > > > > @Echo off > REM > REM Copy files from MainServer to TeraServer > > REM Set variable to current date > set MyDate=%date:~4,2%%date:~7,2%%date:~-2% > > REM Create a subfolder with today's date as the name > MD t:\%MyDate% > > REM Backup folder: Folder1 > echo Started backup of Folder1 at %time%, %date% > BackupLog.txt > xcopy /s /e /i /q /y d:\Folder1 "t:\%MyDate%\Folder1" >> BackupLog.txt > echo Finished Folder1 at %time%, %date% >> BackupLog.txt > echo. >> BackupLog.txt
Guest JohnB Posted July 2, 2008 Posted July 2, 2008 Re: Another batch file question Re: Another batch file question Ah, shoot.... I forgot about the UNC issue with Scheduler. But, I'm testing it using the UNC path and it still isn't working. MD \\Server\testing\%date:~4,2%%date:~7,2%%date:~-2% "testing" is the shared folder. I run that in Scheduler and it completes normally but, the folder doesn't get created. I put your test code in there with it, just to make sure it did "something". I'm stumped again. Any ideas? "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message news:uYNtc3F3IHA.3544@TK2MSFTNGP06.phx.gbl... > Drive T: is probably a mapped share. If it is then it would > not exist under the Task Scheduler session - why should it? > You should use UNC coding for all scheduled tasks. Furthermore, > when debugging scheduled tasks then it is helpful to give yourself > some eyes, e.g. like so: > @echo off > echo %date% %time% %UserName% > c:\test.txt > net use >> c:\test.txt > dir T:\ >> c:\test.txt > xcopy /s /e /i /q /y d:\Folder1 "t:\%MyDate%\Folder1" 1>> c:\test.txt > 2>>&1 > > The contents of c:\test.txt should put an end to you having to > grope blindly for an explanation. > > > "JohnB" <jbrigan@yahoo.com> wrote in message > news:Ohor5GE3IHA.5024@TK2MSFTNGP03.phx.gbl... >> Well it worked when I ran it live. But it didn't work when I ran it in >> Scheduled Tasks. And I can not figure out why. I copied the beginning >> of the batch file below. It copies about 10 folders, only 1 is shown >> there. >> >> It seemed to have failed at the very beginning. There was no folder with >> the current date. It never got created. Which would explain why the >> rest of it failed. So I created a test batch file that only creates the >> folder. Ran it in scheduled tasks, and wouldn't you know, it worked fine. >> >> Any ideas? >> I'm totaly stumped on this one. >> >> TIA >> >> >> >> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message >> news:u7NWRc32IHA.1204@TK2MSFTNGP04.phx.gbl... >>> Thanks for the feedback. >> >> >> >> >> >> @Echo off >> REM >> REM Copy files from MainServer to TeraServer >> >> REM Set variable to current date >> set MyDate=%date:~4,2%%date:~7,2%%date:~-2% >> >> REM Create a subfolder with today's date as the name >> MD t:\%MyDate% >> >> REM Backup folder: Folder1 >> echo Started backup of Folder1 at %time%, %date% > BackupLog.txt >> xcopy /s /e /i /q /y d:\Folder1 "t:\%MyDate%\Folder1" >> BackupLog.txt >> echo Finished Folder1 at %time%, %date% >> BackupLog.txt >> echo. >> BackupLog.txt > >
Guest Pegasus \(MVP\) Posted July 2, 2008 Posted July 2, 2008 Re: Another batch file question Re: Another batch file question Post your final code and the contents of c:\test.txt. "JohnB" <jbrigan@yahoo.com> wrote in message news:%235ezmLH3IHA.4484@TK2MSFTNGP02.phx.gbl... > Ah, shoot.... I forgot about the UNC issue with Scheduler. > > But, I'm testing it using the UNC path and it still isn't working. > > MD \\Server\testing\%date:~4,2%%date:~7,2%%date:~-2% > > "testing" is the shared folder. I run that in Scheduler and it completes > normally but, the folder doesn't get created. I put your test code in > there with it, just to make sure it did "something". I'm stumped again. > > Any ideas? > > > > > "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message > news:uYNtc3F3IHA.3544@TK2MSFTNGP06.phx.gbl... >> Drive T: is probably a mapped share. If it is then it would >> not exist under the Task Scheduler session - why should it? >> You should use UNC coding for all scheduled tasks. Furthermore, >> when debugging scheduled tasks then it is helpful to give yourself >> some eyes, e.g. like so: >> @echo off >> echo %date% %time% %UserName% > c:\test.txt >> net use >> c:\test.txt >> dir T:\ >> c:\test.txt >> xcopy /s /e /i /q /y d:\Folder1 "t:\%MyDate%\Folder1" 1>> c:\test.txt >> 2>>&1 >> >> The contents of c:\test.txt should put an end to you having to >> grope blindly for an explanation. >> >> >> "JohnB" <jbrigan@yahoo.com> wrote in message >> news:Ohor5GE3IHA.5024@TK2MSFTNGP03.phx.gbl... >>> Well it worked when I ran it live. But it didn't work when I ran it in >>> Scheduled Tasks. And I can not figure out why. I copied the beginning >>> of the batch file below. It copies about 10 folders, only 1 is shown >>> there. >>> >>> It seemed to have failed at the very beginning. There was no folder >>> with the current date. It never got created. Which would explain why >>> the rest of it failed. So I created a test batch file that only >>> creates the folder. Ran it in scheduled tasks, and wouldn't you know, it >>> worked fine. >>> >>> Any ideas? >>> I'm totaly stumped on this one. >>> >>> TIA >>> >>> >>> >>> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message >>> news:u7NWRc32IHA.1204@TK2MSFTNGP04.phx.gbl... >>>> Thanks for the feedback. >>> >>> >>> >>> >>> >>> @Echo off >>> REM >>> REM Copy files from MainServer to TeraServer >>> >>> REM Set variable to current date >>> set MyDate=%date:~4,2%%date:~7,2%%date:~-2% >>> >>> REM Create a subfolder with today's date as the name >>> MD t:\%MyDate% >>> >>> REM Backup folder: Folder1 >>> echo Started backup of Folder1 at %time%, %date% > BackupLog.txt >>> xcopy /s /e /i /q /y d:\Folder1 "t:\%MyDate%\Folder1" >> BackupLog.txt >>> echo Finished Folder1 at %time%, %date% >> BackupLog.txt >>> echo. >> BackupLog.txt >> >> >
Guest JohnB Posted July 3, 2008 Posted July 3, 2008 Re: Another batch file question Re: Another batch file question Turned out I had a typo in the UNC path. I fixed that and everything worked fine last night. Thanks for all your help with this. "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message news:uD7eSPI3IHA.5112@TK2MSFTNGP03.phx.gbl... > Post your final code and the contents of c:\test.txt. > > > "JohnB" <jbrigan@yahoo.com> wrote in message > news:%235ezmLH3IHA.4484@TK2MSFTNGP02.phx.gbl... >> Ah, shoot.... I forgot about the UNC issue with Scheduler. >> >> But, I'm testing it using the UNC path and it still isn't working. >> >> MD \\Server\testing\%date:~4,2%%date:~7,2%%date:~-2% >> >> "testing" is the shared folder. I run that in Scheduler and it completes >> normally but, the folder doesn't get created. I put your test code in >> there with it, just to make sure it did "something". I'm stumped again. >> >> Any ideas? >> >> >> >> >> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message >> news:uYNtc3F3IHA.3544@TK2MSFTNGP06.phx.gbl... >>> Drive T: is probably a mapped share. If it is then it would >>> not exist under the Task Scheduler session - why should it? >>> You should use UNC coding for all scheduled tasks. Furthermore, >>> when debugging scheduled tasks then it is helpful to give yourself >>> some eyes, e.g. like so: >>> @echo off >>> echo %date% %time% %UserName% > c:\test.txt >>> net use >> c:\test.txt >>> dir T:\ >> c:\test.txt >>> xcopy /s /e /i /q /y d:\Folder1 "t:\%MyDate%\Folder1" 1>> c:\test.txt >>> 2>>&1 >>> >>> The contents of c:\test.txt should put an end to you having to >>> grope blindly for an explanation. >>> >>> >>> "JohnB" <jbrigan@yahoo.com> wrote in message >>> news:Ohor5GE3IHA.5024@TK2MSFTNGP03.phx.gbl... >>>> Well it worked when I ran it live. But it didn't work when I ran it in >>>> Scheduled Tasks. And I can not figure out why. I copied the beginning >>>> of the batch file below. It copies about 10 folders, only 1 is shown >>>> there. >>>> >>>> It seemed to have failed at the very beginning. There was no folder >>>> with the current date. It never got created. Which would explain why >>>> the rest of it failed. So I created a test batch file that only >>>> creates the folder. Ran it in scheduled tasks, and wouldn't you know, >>>> it worked fine. >>>> >>>> Any ideas? >>>> I'm totaly stumped on this one. >>>> >>>> TIA >>>> >>>> >>>> >>>> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message >>>> news:u7NWRc32IHA.1204@TK2MSFTNGP04.phx.gbl... >>>>> Thanks for the feedback. >>>> >>>> >>>> >>>> >>>> >>>> @Echo off >>>> REM >>>> REM Copy files from MainServer to TeraServer >>>> >>>> REM Set variable to current date >>>> set MyDate=%date:~4,2%%date:~7,2%%date:~-2% >>>> >>>> REM Create a subfolder with today's date as the name >>>> MD t:\%MyDate% >>>> >>>> REM Backup folder: Folder1 >>>> echo Started backup of Folder1 at %time%, %date% > BackupLog.txt >>>> xcopy /s /e /i /q /y d:\Folder1 "t:\%MyDate%\Folder1" >> BackupLog.txt >>>> echo Finished Folder1 at %time%, %date% >> BackupLog.txt >>>> echo. >> BackupLog.txt >>> >>> >> > >
Guest Pegasus \(MVP\) Posted July 3, 2008 Posted July 3, 2008 Re: Another batch file question Re: Another batch file question "JohnB" <jbrigan@yahoo.com> wrote in message news:%23f6X3YQ3IHA.1192@TK2MSFTNGP05.phx.gbl... > Turned out I had a typo in the UNC path. I fixed that and everything > worked fine last night. > > Thanks for all your help with this. Thanks for the feedback.
Recommended Posts