1

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\
cd blah\blah\blah
copy *.txt Q:\blahdrive /y
Exit
--- 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 –  May 31 '12 at 10:08

1 Answers1

1

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.

Brent Pabst
  • 6,069
  • 2
  • 24
  • 36
  • ^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 01 '12 at 00:21
  • Q is also the default AppV/softgrid drive, and you can't copy things like that to it. – Gomibushi Jun 01 '12 at 12:30