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.