使用xcopy遇到的一个问题

 我需要从远端的服务器拷贝一个大的目录(>1G)到本机,在Console中我使用了xcopy命令。过了几十分钟之后,在copy一个大的文件(大约500M)时出现了错误:

                        File creation error - the specified network name is no longer available.

不知道这个错误什么意思,在google上搜索了一下,找到了一篇好的文章:http://www.xxcopy.com/xxgroup/m08/msg08400.htm。Garry很细心,对很多情况进行了测试。得出的结果是:造成这个错误是由于网络连接不好导致的。没有办法,只能让远程机器开一个ftp给我用。

 

我把这篇文章贴在最后:

 

--- In xxcopy@yahoogroups.com, "dcohn99"  wrote:
> As to your very detailed response, thank you, but my question
> still comes down to why are other applications able to display
> and/or copy the files from the system in question. Examples
> like Dir and xcopy.


I did some testing across a lan using a similar setup as Doug
has described although I don't have an ME machine so couldn't
duplicate it exactly. To simulate a network problem, I tried
two methods:

1. I removed the cable - permanent disconnection
2. On the remote PC, I closed the connection several times with
a NET SESSION //PC /D /Y. This results in a brief disconnection
until windows re-establishes the connection.

Here's a summary of what I tried and the results. In each case,
the source was a remote PC (either mapped to a drive or via
UNC) and the dest was local. The xxcopy/xcopy command was a
simple copy to an empty destination. The source consisted of
19 files between 1.5Mb and 4.2Mb.

Test 1.
=======
src=mapped drive on W2k
dst=local NT4
command=xxcopy n:/test/ d:/test/ /bu/pb/onxxcopy.log/oe3

1. When the plug was pulled, xxcopy/windows waited approx 90secs
then terminated with exit code 101. The error reported by xxcopy
was #240 "Unspecified system error". NET HELPMSG 240 gives this
as "The session was cancelled". Not all files were copied.

If the cable was re-connected during the wait state, the copying
continued unabated and terminated normally.

2. When the session was closed, xxcopy immediately issued a
"Copy failed" message on the console then the copying continued
with the next file and terminated with exit code 100+no of
failed copies and error #240 as for 1.

Test 2. As for 1 but swapped PC's
=======
src=mapped drive on NT4
dst=local W2k
command=xxcopy n:/test/ d:/test/ /bu/pb/onxxcopy.log/oe3

1. When the plug was pulled, xxcopy/windows waited approx 90secs
then terminated with exit code 101. The error reported by xxcopy
was #64 "The specified network name is gone". NET HELPMSG 64
gives this as "The specified network name is no longer available"

If the cable was re-connected during the wait state, the copying
continued unabated and terminated normally.

2. When the session was closed, xxcopy immediately issued a
"Copy failed" message on the console then the copying continued
with the next file and terminated with exit code 100+no of failed
copies and error #64 as for 1 but on one occassion gave error #6
"Incorrect internal file identifier". NET HELPMSG 6 gives this
as "The handle is invalid".

Test 3. As for 2 but using /cr30
=======
src=mapped drive on NT4
dst=local W2k
command=xxcopy n:/test/ d:/test/ /bu/pb/onxxcopy.log/oe3/cr30

2. Exactly the same as above i.e. /cr30 had no effect.

Test 4. As for 3 but using UNC src
=======
src=UNC drive on NT4
dst=local W2k
command=xxcopy //pc/d/test/ d:/test/ /bu/pb/onxxcopy.log/oe3/cr30

2. Exactly the same as above i.e. UNC made no difference.

Test 5. As for 2 but using xcopy
=======
src=mapped drive on NT4
dst=local W2k
command=xcopy n:/test/* d:/test/ /s/c

1. When the plug was pulled, xcopy/windows waited approx 50secs
then terminated with exit code 0!! The console listed multiple
"Unable to create directory ....." followed by "File creation
error - the network path was not found".

If the cable was re-connected during the wait state, the copying
continued unabated and terminated normally.

2. When the session was closed, xcopy continued with the copy
and copied the files normally. However if the session was
closed repeatedly with no pause between each closure, xcopy
issued a "File creation error - the specified network name
is no longer available" (this is the same as #64 above).
If the session was left to then re-establish itself, xcopy
continued copying the remaing files and terminated with
exit code 0.


So the conclusions that might be drawn from this.

1. The #error codes reported by windows/xxcopy with /oe3 are
system dependent. NT4 reported different error numbers to W2k
for the same error condition. The #error codes reported by
Doug on ME are different again however the descriptions in
all cases are similar.

2. Xxcopy reports a 101 "success" code even when the cable
is pulled and the source is permanently lost. Xxcopy then
stops copying (or trying to copy) any further files and
terminates. This is however a lot better than xcopy's 0
exit code although it does at least list the file names
of the failed copies to the console.

3. Xxcopy doesn't re-try on failed network access errors
even temporary disconnects. Xcopy does wait for a while
(not certain how long - about 5-10 secs).

4. Don't rely on either xxcopy's or xcopy's exit code as
the sole determinant of the success or failure of a
network copy. Xxcopy exit code 101 or higher may be a
critical error. Xcopy exit code 0 may be a critical error.
I guess system admins need to make sure they use /oe2 or
/oe3 and check the logs for critical #error_nos.

5. I'm not sure why xxcopy terminates when the network
cable is disconnected and a #64 error results but continues
when the session is closed and a #64 error results.
Similarly, I don't know why xxcopy/windows waits 90 secs
on a cable disconnect but xcopy waits 50 secs. Maybe
there is further status checking within xxcopy which
determines whether xxcopy terminates.

6. I couldn't replicate Doug's #55 error which resulted
in a termination of xxcopy but presumably it is similar
to the W2k #64 errors and the status reports look like
a permanent disconnection on an ME system.

Garry
### 如何在批处理文件中正确使用 `xcopy` 命令 在 Windows 的批处理脚本 (`.bat`) 中,可以利用 `xcopy` 命令来实现复杂的文件和目录复制操作。以下是关于如何正确配置并执行该命令的具体说明。 #### 使用方法概述 `xcopy` 是一种增强型的文件复制工具,支持多种参数设置以满足不同的需求。其基本语法如下: ```plaintext xcopy [源文件路径] [目标文件路径] [选项] ``` 其中 `[源文件路径]` 和 `[目标文件路径]` 表示要复制的数据所在位置以及存储的目标位置;而 `[选项]` 则定义了具体的复制行为[^1]。 #### 参数详解 为了更好地控制复制过程,可以通过指定不同开关来自定义功能。一些常用的选项包括但不限于以下几个方面: - `/E`: 复制所有子目录,即使它们为空。 - `/C`: 即使发生错误也继续复制其余文件。 - `/H`: 同样复制隐藏及系统文件。 - `/R`: 覆盖只读文件。 - `/Y`: 不提示确认就自动覆盖已存在的目的地文件[^3]。 例如,在实际应用当中如果想要把整个目录连同内部结构一起迁移到另一处地方,则可采用下面这条指令形式完成任务: ```batch @echo off xcopy "C:\source\" "D:\destination\" /E /H /C /R /Y pause ``` 上述例子展示了怎样通过编写简单的 `.bat` 文件来进行批量数据转移工作,并且加入了安静模式 (`@echo off`) 防止多余信息干扰视觉效果,最后还设置了暂停以便观察运行结果后再关闭窗口[^2]。 #### 错误处理注意事项 当尝试某些敏感区域或者缺乏适当权限时可能会遇到诸如 "[Errno 13] Permission denied" 这样的警告消息提醒我们没有足够的权利去修改特定资源。因此建议始终确保拥有必要访问许可的前提下再实施相应动作。 ### 示例代码片段 这里提供了一个完整的示范案例供参考学习: ```batch :: 创建一个新的批处理文件 test.bat 并输入以下内容保存即可测试 @echo off set source=C:\example_source_folder\ set destination=D:\example_destination_folder\ if not exist "%destination%" mkdir "%destination%" xcopy "%source%*" "%destination%" /E /H /C /R /Y echo Files copied successfully. pause exit ``` 此脚本首先声明变量分别指向原地址与目的址,接着检查后者是否存在不存在的话先建立起来,之后运用之前提到过的那些常用标志位启动真正的拷贝流程直至结束给出成功通知等待用户按键才退出程序^.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值