xcopy stops working in batch file when I connect to machine using remote desktop connection

R

Roveer

I've got a very strange problem. I originally set up a batch file
that runs each night at 3:30am using nnKron lite. It among other
things xcopy's a bunch of directories from another machine, RAR's them
in preparation for on-line backup which starts some time later.

This system worked great for months and months giving me piece of mind
that many criticial files were being backed up. I then started
noticing failures. The batch file runs, but the xcopy commands
contained within that batch file did not execute thus not copying the
files to the local machine. This only fails if I connect to the
machine using remote desktop connection which I often will do when at
my other worksite. The xcopy's will fail until I reboot the machine,
then all will be normal again until I make a RDC to the machine then
back to failure. I've tried tweaking the batch file several times
going as far as putting full path names to the xcopy.exe in case for
some reason the "path" changed after RDC.

Any ideas on what's going on here? I need my batch file to work, but
I also need to access the machine remotely using RDC. This one has me
stumped.

Roveer
 
P

Pegasus \(MVP\)

Roveer said:
I've got a very strange problem. I originally set up a batch file
that runs each night at 3:30am using nnKron lite. It among other
things xcopy's a bunch of directories from another machine, RAR's them
in preparation for on-line backup which starts some time later.

This system worked great for months and months giving me piece of mind
that many criticial files were being backed up. I then started
noticing failures. The batch file runs, but the xcopy commands
contained within that batch file did not execute thus not copying the
files to the local machine. This only fails if I connect to the
machine using remote desktop connection which I often will do when at
my other worksite. The xcopy's will fail until I reboot the machine,
then all will be normal again until I make a RDC to the machine then
back to failure. I've tried tweaking the batch file several times
going as far as putting full path names to the xcopy.exe in case for
some reason the "path" changed after RDC.

Any ideas on what's going on here? I need my batch file to work, but
I also need to access the machine remotely using RDC. This one has me
stumped.

Roveer

You need to report the exact xcopy command you use and
what error message you see when it fails. Remember - we cannot
see your machine! Try this:

xcopy {switches} {Source} {Destination} 1>c:\xcopy.txt 2>&1

Let's have a look at c:\xcopy.txt!
 
B

Bob I

A couple things to check. Are you using UNC paths? Is the batch file
running under the system account, or an auto login?
 
R

Roveer

A couple things to check. Are you using UNC paths? Is the batch file
running under the system account, or an auto login?







- Show quoted text -

Here's the xcopy syntax (which works just fine if the machine is
logged in as the user with admin priv's. It'll work just fine for
weeks at a time even with the screen saver engaged. It only stops
working when I remote desktop connect to the maching (using the exact
same user name that it normally runs under).

c:\windows\system32\xcopy /S /C /Z /I "M:\MS Excel" "c:\Server Backup
\Day 1\MS Excel" >> "c:\Server Backup\day 1\Backup.log"

I can't say what it's doing as far as erroring as this batch file runs
at 3:30am each morning. I guess I could disable the screen saver and
put a video camera on it, but I would also think that if there were an
error it would flash by so quickly that I wouldn't be able to see it
anyway. Guess I could put a pause command after the xcopy statement
one night to see what it says. Any other suggestions?

Remember, if I launch it manually it works just fine. If I let nncron
lite run it normally it runs fine. It's only after I RDC to the
machine using the same user name (during the day), and then disconnect
does it screw up. BTW, all of the other commands in the batch file
run correctly, it just seems to be the xcopy that screws up.

Roveer
 
B

Bob I

Roveer said:
Here's the xcopy syntax (which works just fine if the machine is
logged in as the user with admin priv's. It'll work just fine for
weeks at a time even with the screen saver engaged. It only stops
working when I remote desktop connect to the maching (using the exact
same user name that it normally runs under).

c:\windows\system32\xcopy /S /C /Z /I "M:\MS Excel" "c:\Server Backup
\Day 1\MS Excel" >> "c:\Server Backup\day 1\Backup.log"

I can't say what it's doing as far as erroring as this batch file runs
at 3:30am each morning. I guess I could disable the screen saver and
put a video camera on it, but I would also think that if there were an
error it would flash by so quickly that I wouldn't be able to see it
anyway. Guess I could put a pause command after the xcopy statement
one night to see what it says. Any other suggestions?

Remember, if I launch it manually it works just fine. If I let nncron
lite run it normally it runs fine. It's only after I RDC to the
machine using the same user name (during the day), and then disconnect
does it screw up. BTW, all of the other commands in the batch file
run correctly, it just seems to be the xcopy that screws up.

Roveer

Using the UNC path for "M:\MS Excel" may correct the problem.
 
R

Roveer

Using the UNC path for "M:\MS Excel" may correct the problem.- Hide quoted text -

- Show quoted text -

OK, I've done a lot of testing and here's what I've found.
From the pc that executes the batch file I have a perpetual drive
mapping for drive M: to a windows xp machine that we call our server,
just regular xp pro. From my PC, I can always see drive m:, when I
RDC to my pc and opening a dos box or through file manager I can see
drive m: When my PC is on a fresh boot and logged in as my username I
can see drive m:, in and out of screen saver I can see drive m: Once
I RDC my desktop from another PC and then disconnect from my pc, any
batch file that runs on my PC that attempts to do anything with Drive
m: can NOT see drive m:

I modified a simple batch file to do the following:

m:
cd \MS EXCEL
DIR
XCOPY files from drive m: to drive c: (syntax omitted)

This batch file works just fine when I am logged in at my pc, it works
just great until I do a RDC and then disconnect. Also works from a
RDC session!!! Once I've RDC'd and disconnected from the PC and let
cron run the batch file I get the following errors:

"The system cannot find the path specified" (for the M: and CD \ms
excel)
the DIR command produces a directory of drive c: (because it failed to
switch to drive m:)
The xcopy command produces a "Invalid Drive Specification" error
message

If I log back into my PC after the RDC connection (at the actual PC),
I can see drive M: just fine, the simple batch file runs with no
problem etc.

So,

Why do I not have access to the network share (drive M:) after I RDC
the PC for cron to do it's thing? This one has me boggled. I need to
make this batch file run and I often RDC my machine when I'm on the
road.

Oh, tried UNC pathing and it does not make a difference, works when
logged in, fails once I've RDC'd and disconnected.

Any ideas?
 
B

Bob I

Roveer said:
OK, I've done a lot of testing and here's what I've found.

mapping for drive M: to a windows xp machine that we call our server,
just regular xp pro. From my PC, I can always see drive m:, when I
RDC to my pc and opening a dos box or through file manager I can see
drive m: When my PC is on a fresh boot and logged in as my username I
can see drive m:, in and out of screen saver I can see drive m: Once
I RDC my desktop from another PC and then disconnect from my pc, any
batch file that runs on my PC that attempts to do anything with Drive
m: can NOT see drive m:

I modified a simple batch file to do the following:

m:
cd \MS EXCEL
DIR
XCOPY files from drive m: to drive c: (syntax omitted)

This batch file works just fine when I am logged in at my pc, it works
just great until I do a RDC and then disconnect. Also works from a
RDC session!!! Once I've RDC'd and disconnected from the PC and let
cron run the batch file I get the following errors:

"The system cannot find the path specified" (for the M: and CD \ms
excel)
the DIR command produces a directory of drive c: (because it failed to
switch to drive m:)
The xcopy command produces a "Invalid Drive Specification" error
message

If I log back into my PC after the RDC connection (at the actual PC),
I can see drive M: just fine, the simple batch file runs with no
problem etc.

So,

Why do I not have access to the network share (drive M:) after I RDC
the PC for cron to do it's thing? This one has me boggled. I need to
make this batch file run and I often RDC my machine when I'm on the
road.

Oh, tried UNC pathing and it does not make a difference, works when
logged in, fails once I've RDC'd and disconnected.

Any ideas?

I'm having difficulty following which PC you are logging in on vs. which
one the batchfile file is running on vs. which one you can see "M" from
and which PC you can't make work unless you reboot!

If you are remoting into a PC, YOU are the only one logged into the PC.
When you disconnect no one is logged on. I presume that is when your
batch file stops working on the PC that you are remoting into? If that
is the case, perhaps setting the batch file to run under an
administrators account with Task Scheduler and UNC pathing will be the
answer.
 
P

Pegasus \(MVP\)

Roveer said:
OK, I've done a lot of testing and here's what I've found.

mapping for drive M: to a windows xp machine that we call our server,
just regular xp pro. From my PC, I can always see drive m:, when I
RDC to my pc and opening a dos box or through file manager I can see
drive m: When my PC is on a fresh boot and logged in as my username I
can see drive m:, in and out of screen saver I can see drive m: Once
I RDC my desktop from another PC and then disconnect from my pc, any
batch file that runs on my PC that attempts to do anything with Drive
m: can NOT see drive m:

I modified a simple batch file to do the following:

m:
cd \MS EXCEL
DIR
XCOPY files from drive m: to drive c: (syntax omitted)

This batch file works just fine when I am logged in at my pc, it works
just great until I do a RDC and then disconnect. Also works from a
RDC session!!! Once I've RDC'd and disconnected from the PC and let
cron run the batch file I get the following errors:

"The system cannot find the path specified" (for the M: and CD \ms
excel)
the DIR command produces a directory of drive c: (because it failed to
switch to drive m:)
The xcopy command produces a "Invalid Drive Specification" error
message

If I log back into my PC after the RDC connection (at the actual PC),
I can see drive M: just fine, the simple batch file runs with no
problem etc.

So,

Why do I not have access to the network share (drive M:) after I RDC
the PC for cron to do it's thing? This one has me boggled. I need to
make this batch file run and I often RDC my machine when I'm on the
road.

Oh, tried UNC pathing and it does not make a difference, works when
logged in, fails once I've RDC'd and disconnected.

Any ideas?

As Bob says: Do not use mapped drives for background jobs.
They may be unavailable for several reasons. Use UNC
coding instead. And as I suggested in my first reply: Capture
the error output from xcopy.exe, not just the standard ouput!
 
R

Roveer

quoted text -










As Bob says: Do not use mapped drives for background jobs.
They may be unavailable for several reasons. Use UNC
coding instead. And as I suggested in my first reply: Capture
the error output from xcopy.exe, not just the standard ouput!- Hide quoted text -

- Show quoted text -

Well after a day of futzing around with this and finding various
situations where the computer would not allow network access after
having been RDC'd I took bob's advice and used the windows task
scheduler with basically the same batch file and it appears to work.
I made sure the batch file was set to run with my priv's, set task
scheduler to run the batch file 5 mins in the future, RDC'd from
another computer to this computer, disconnected waited for the task
scheduler to run and everything went smoothly. I've set it back up to
run at 2:30am so tomorrow we'll see what we've got. Possibly nnCron
did not have the right priv's to run??? Who knows, all I need is for
this thing to work.

Regards,

Roveer
 
R

Roveer

Well after a day of futzing around with this and finding various
situations where the computer would not allow network access after
having been RDC'd I took bob's advice and used the windows task
scheduler with basically the same batch file and it appears to work.
I made sure the batch file was set to run with my priv's, set task
scheduler to run the batch file 5 mins in the future, RDC'd from
another computer to this computer, disconnected waited for the task
scheduler to run and everything went smoothly. I've set it back up to
run at 2:30am so tomorrow we'll see what we've got. Possibly nnCron
did not have the right priv's to run??? Who knows, all I need is for
this thing to work.

Regards,

Roveer- Hide quoted text -

- Show quoted text -

Seems to have worked just fine last night. Did everything I needed it
to. Thanks to all who provided suggestions.

Roveer
 
B

Bob I

Roveer said:
Seems to have worked just fine last night. Did everything I needed it
to. Thanks to all who provided suggestions.

Roveer

You're welcome, I would still use UNC pathing for this rather than drive
letters for remote drive access in unattended batch files.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top