RDP xcopy failing when logged off

I have a dos batch file that runs on a local server that connects to outside servers, maps a drive with net use, and copies files using xcopy.  The batch file is scheduled to run using Windows.
I connect to the local server (Windows 2003) using RDP on my local machine (Vista).  The batch file runs perfectly as long as I stay logged on to RDP, but as soon as my session expires or I log off, the xcopy command stops working.
rasdial "Customer VPN" xxx xxxxxx
@echo VPN connection had a return code of %errorlevel% >> c:\log.txt
net use x: \\xx.x.x.x\custdata /user:domain\xxx xxxxxx
@echo Net Use had a return code of %errorlevel% >> c:\log.txt
xcopy f:\mydata\data\task.dbf x:\customer\Data /y
@echo Task dbf file copy had a return code of %errorlevel% >> c:\log.txt

When logged in all return codes are zero.  When logged off all are zero except the last one, the xcopy has a return code of 4.

F:\ is a local drive mapped on my local server.  I am wondering if RDP is not keeping that drive mapped when logged off, or the local server is not keeping it mapped when logged off, or if there is something else wrong?
Some additional info:  My company had a server crash (not the one I'm using) a while back and everything worked perfectly before that.  At that time the server I was using became the main production server and my processes were temporarily stopped for a couple of months.  When I recently started these processes again is when my issue showed up.  So the possibility exists that something was changed from an admin point of view on the server regarding RDP/drive mappings.

I need to be logged off and have the xcopy work correctly.  My current workaround is to stay logged on all day long, but if I'm away from my desk for any extended period of time, my session times out and the copy fails.

Thanks for your help.
LVL 4
wigmeisterAsked:
Who is Participating?
 
Steve KnightIT ConsultancyCommented:
When you say that F:\ is a local drive mapped on my local server if this is to another resource on your domain best bet is to use the UNC path - if a user is logged in to the server then it will have drives mapped under it's login but if logged off then there will be no mapped drives.

i.e.

@echo off
rasdial "Customer VPN" xxx xxxxxx
@echo VPN connection had a return code of %errorlevel% >> c:\log.txt
net use x: \\xx.x.x.x\custdata /user:domain\xxx xxxxxx 2>> c:\log.txt
@echo Net Use had a return code of %errorlevel% >> c:\log.txt
xcopy \\server\share\myata\data\task.dbf x:\customer\Data /d /y 2>> c:\log.txt
@echo Task dbf file copy had a return code of %errorlevel% >> c:\log.txt
net use x: /delete

The /d on xcopy will not copy it unless it has changed which may be approriate too and the 2>> will redirect any error output from those commands to the log too.

Steve
0
 
WindowsITAdminCommented:
Hi.
The scheduled task with what credentials run?

Hope this helps.
0
 
wigmeisterAuthor Commented:
The scheduled dos batch file runs under my id in Windows Scheduled Tasks.  It doesn't run under admin.  It runs every half-hour and the code in my question write-up is part of the code in that dos batch file.  Not sure if that is what you were asking for or not.  
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
WindowsITAdminCommented:
Yes, that's what i was asking for but I don't know why it's not working...

The error is "4 - Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line."

I understand that it's "path not found", it seems that it can't map the network drive and xcopy fails...

I'm sorry but I don't know how to fix it.

Good luck.
0
 
wigmeisterAuthor Commented:
Saved me again, Dragon!  Thank you very much.
0
 
Steve KnightIT ConsultancyCommented:
No problem... and thankyou.  Your points have tipped me over into being a "Sage" in Windows Batch scripting... whatever one of those is!!

You have achieved Sage Certification in Windows Batch Scripting by earning 501,692 points!  To celebrate your new rank, Experts Exchange would like to send you a free official Experts Exchange certified Shirt.

        Sage
        Windows Batch Scripting
        501,692
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.