Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 ---
share|improve this question

migrated from stackoverflow.com May 31 '12 at 13:54

This question came from our site for professional and enthusiast programmers.

    
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
add comment

1 Answer

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.

share|improve this answer
    
^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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.