Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8720483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:03:06+00:00 2026-06-13T07:03:06+00:00

I have a scheduled task in Windows Server 2003 R2 that is supposed get

  • 0

I have a scheduled task in Windows Server 2003 R2 that is supposed get some files from a network location (mapped drive) and copy them to a local folder in preparation for an FTP sync to a mobile device later that day.

The task runs no problem when I click it and run it. Task scheduler says it is running updates the time it has run and the files appear in the correct location. Yet…

When the task is supposed to run over night (and I am not already logged in) the task runs (task scheduler indicates that the task ran at the specified time) but the file copy does not occur. I suspect this has to do with the task logging the account in, then running the file copy before the Network Drive has been connected and is ready.

Here is my code from the batch file:

@echo off

FORFILES /p "K:\Oncology\BSWRICS-MDM" /s /m *.* /c "cmd /c Del @path" /d -30

set "cleanup=K:\Oncology\BSWRICS-MDM"

for /f "usebackq tokens=*" %%a in (`dir /b/s/ad "%cleanup%" ^| sort /r`) do (rmdir "%%~a" 2>nul && echo:Removed: "%%a")

xcopy  K:\Oncology\BSWRICS-MDM\*.* C:\wamp\www\Portal\files\BSWRICS-MDM /Y /S 

FORFILES /p "C:\wamp\www\Portal\files\BSWRICS-MDM" /s /m *.* /c "cmd /c Del @path" /d -30

The first few lines delete files older than 30 days from the local folder, then the xcopy occurs. As I said, this script works perfectly when I log in first.

Is there some code I can insert at the start to have the script check if the network drive is ready and only if TRUE, proceed to the next instruction?

Some answers to expected questions:
– The network drive letter never changes.
– The account that logs in with the scheduled task is the same one I can successfully run the task from.
– The task actually runs (logged in task scheduler) but there is no evidence of the file copy having been performed.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:03:07+00:00Added an answer on June 13, 2026 at 7:03 am

    You could delete the mapped drive and try to map it again, and then wait until the errorlevel shows it is connected before proceeding.

    @echo off
    :LOOP
    net use Y: /delete
    net use Y: \\server\share
    if errorlevel 1 (
    goto :ERROR
    ) else (
    goto :OK
    )
    
    :ERROR
    echo ERROR!
    rem Try again!
    timeout /t 5
    goto :LOOP
    
    :OK
    echo OK!
    rem Carry on!
    pause >nul
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scheduled task running on a Windows Server 2008 R2 that is
We have several apps that run on a Windows 2003/2008 server. Some of these
I have a batch file on a Windows 2008 server that, when invoked from
I have scheduled my batch file in task scheduler in windows server 2008. Task
I have an interesting/annoying problem with some VBScripts running on Windows 2003 Server (they
I have a Windows 2003 Server that uses IIS to host a legacy ASP.NET
I have a C# program that will run as a windows scheduled task. This
I have a .NET console app running on Windows Server 2003, as a scheduled
I have a scheduled task that is very IO intensive (deleting hundreds of thousands
I want to have an operation(Task) to be Scheduled after some time OR Based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.