『第
4 楼』:
@echo off&setlocal enabledelayedexpansion
::查找有共享的电脑
for /l %%i in (1,1,225) do (
cls&echo 正在扫描 192.168.0.1-192.168.0.225 请等待...&echo.&ping /n 1 192.168.0.%%i|find "Reply"&&net view \\192.168.0.%%i|find "命令成功完成"&&for /l %%j in (1,1,3) do echo 192.168.0.%%i>>ip.txt
)
::查看并映射相应ip的共享资源
cls
set /p choose=扫描完成,是否浏览共享资源[y/n]
if not %choose%==y goto eof
for /f %%i in (ip.txt) do (
cls&echo ip为%%i的电脑上的共享资源如下:&echo.
set num=0&set choose2=&set flag=&set flag2=
::测算共享名的长度,因为有英文和中文并存,所以长度只能大概测算
for /f "skip=4 tokens=*" %%j in ('net view \\%%i') do (set /a flag+=1&if !flag!==1 call :pick %%j)
set /a line=!line!-!line!/4
::获取共享资源列表
for /f "skip=7 tokens=*" %%j in ('net view \\%%i') do (if not "%%j"=="命令成功完成。" (set /a num+=1&set str=%%j&call set str=%%str:~0,!line!%%&set "explor!num!=!str!"&set str2=!num!-----&set str2=!str2:~0,6!&echo !str2!!str!))
echo.&set /p choose2=选择一个要映射的资源:
::去掉变量最后的空格,不然在映射时会出错
call set var=%%explor!choose2!%%&call :delspace !var!
::随机选择盘符
for %%k in (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,o,v,w,x,y,z) do (cd %%k: >nul 2>nul||(set /a flag2+=1&if !flag2!==1 (net use %%k: "\\%%i\!explorname!"&pause)))
)
goto eof
:pick
set line=3
set "str=%*"
:loop
if "%str:~0,1%"=="类" goto eof
set str=!str:~1!&set /a line+=1&goto loop
:delspace
set "explorname=%*"
:loop2
if not "%explorname:~-1%"=="" goto eof
set str=%explorname:~0,-1%&goto loop2
:eof 先PING看看通不通 然后再PING通的机里面扫 最后映射....
转非常P处理 WANK-OILZ版主的~~
[ Last edited by p1509101 on 2008-4-13 at 03:31 PM ]
|