求助如何给局域网中其它电脑发送文件到指定目录
下面代码不成功,在copy %~dp0tip\*.* V:\ | find "已复制" && echo %%i >>CpDone.txt 不成功,请帮助!- ::@echo off
- ::copy good bat files to users c:\windows
-
- set /p netid=Input current IP loop pls(eg:10.128.238)=
- set /p Sip= Start IP(start IP)=
- set /p Eip= End IP(End IP)=
- set /p Psw= Input Admin Password pls=
-
- del alive.txt
-
- ::If PC is live ?
- for /L %%a in (%Sip%,1,%Eip%) do ping -n 1 %netid%.%%a | find "from" && echo %%a >>alive.txt
-
- ::Create a connection & Copy batFiles to c:\windows
- for /f %%i in (alive.txt) do (
- net use V: \\%netid%.%%i\c$\windows /user:localhost\administrator %Psw%
- copy %~dp0tip\*.* V:\ | find "已复制" && echo %%i >>CpDone.txt
- net use V: /d)
-
- :: "%~dp0" mean is get current file path
- pause
复制代码 程序运行的结果如下:
C:\Documents and Settings\SFX\桌面\send>set /p netid=Input current IP loop pls(eg:10.128.238)=
Input current IP loop pls(eg:10.128.238)=10.128.238
C:\Documents and Settings\SFX\桌面\send>set /p Sip= Start IP(start IP)=
Start IP(start IP)=30
C:\Documents and Settings\SFX\桌面\send>set /p Eip= End IP(End IP)=
End IP(End IP)=30
C:\Documents and Settings\SFX\桌面\send>set /p Psw= Input Admin Password pls=
Input Admin Password pls=password
C:\Documents and Settings\SFX\桌面\send>del alive.txt
C:\Documents and Settings\SFX\桌面\send>for /L %a in (30 1 30) do ping -n 1 10.128.238.%a | find "from" && echo %a 1>>alive.txt
C:\Documents and Settings\SFX\桌面\send>ping -n 1 10.128.238.30 | find "from" && echo 30 1>>alive.txt
Reply from 10.128.238.30: bytes=32 time<1ms TTL=128
C:\Documents and Settings\SFX\桌面\send>for /F %i in (alive.txt) do (
net use V: [url=file://\\10.128.238.%i\c$\windows]\\10.128.238.%i\c$\windows[/url] /user:localhost\administrator password
copy C:\Documents and Settings\SFX\桌面\send\tip\*.* V:\ | find "已复制" && echo %i 1>>CpDone.txt
net use V: /d
)
C:\Documents and Settings\SFX\桌面\send>(
net use V: [url=file://\\10.128.238.30\c$\windows]\\10.128.238.30\c$\windows[/url] /user:localhost\administrator password
copy C:\Documents and Settings\SFX\桌面\send\tip\*.* V:\ | find "已复制" && echo 30 1>>CpDone.txt
net use V: /d
)
命令成功完成。
V: 已经删除。
C:\Documents and Settings\SFX\桌面\send>pause
请按任意键继续. . .
似乎看起来没问题,可是让我去看10.128.238.30的C:\WINDOWS下根本就没有找到被复制的文件。
PS . 之前用绝对路径COPY了一个KNOTES.BAT(TIP文件夹中的一个文件)到10.128.238.30\c$\windows下,改了代码为了测试,我删除了KNOTES.BAT再运行便出现了上面说的不成功
[ 本帖最后由 coolcatsfx 于 2009-4-3 14:05 编辑 ] |