I have written a simple bat file to copy .txt files from one drive into another one. I want this to run everyday at this time but the problem is when I'm not logged in to the server the task does not run. I have also selected the "Run whether logged in or not".

--- script ---
@echo off
cd blah\blah\blah
copy *.txt Q:\blahdrive /y
--- script ---
  • Provide the version of the windows server you are using. BTW, I feel that it is more a question for Server-Fault than SO – Seki May 31 '12 at 10:02
  • Windows server 2008 R2 Standard – user1383080 May 31 '12 at 10:08

It's hard to tell but are you trying to copy files to a Network Share or Mapped Drive? Q is pretty high for a local disk so I'm assuming that's what you are doing. Mapped Drives/Network Shares only exist when you are logged into the machine. The connection to the drive is dropped once you logoff. Therefore you cannot copy files to a mapped drive unless a user is logged in.

However, you can use UNC file paths to the server or you can use the NET USE command to setup a temporary session to the drive. UNC path is probably the easiest to implement.

  • ^This. Sometimes batch doesn't like UNC paths so much though, so if you need to use net use just put it right after @echo off: net use Q: \\blahserver\blahdrive /user:domain\username password – iesou May 31 '12 at 20:35
  • Agreed, Mapped Drive support without an open profile in Windows pretty much sucks. To be safe always hit it with NET USE. – Brent Pabst Jun 1 '12 at 0:21
  • Q is also the default AppV/softgrid drive, and you can't copy things like that to it. – Gomibushi Jun 1 '12 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy