广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 4922 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
炎峰
数位造型
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x1
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[提问] 请问...批次档问题!
小弟是个超级新手...

请问各位大大~

(1) 假如我想写一个.cmd

在开始之前它会问是否执 ..

访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容



献花 x1 回到顶端 [楼 主] From:台湾中华电信HINET | Posted:2007-07-22 16:57 |
yc421206 手机
个人头像
个人文章 个人相簿 个人日记 个人地图
初露锋芒
级别: 初露锋芒 该用户目前不上站
推文 x0 鲜花 x19
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

下面是引用炎峰于2007-07-22 16:57发表的 请问...批次档问题!:
小弟是个超级新手...
http://www.cn-dos.ne...cht.htm
中 国 DOS 联 盟
请问各位大大~

(1) 假如我想写一个.cmd
.......


诺~小弟写的小东东是要ping ip address,本是想写ping 整个区段的, 表情
但不知是批指令笨还是我笨,我越写越多,最后放弃!目前只完成了class c   表情
你就免强用这范例当学习吧 表情
如果你有看不懂的指令可以去http://www.cn-dos.net/forum/forum...=23&sid=YUS28M
里面很多高手的唷,祝你一切顺心 ,加油表情
以下为source code
_____________________________________
复制程式
@echo off
:proceed_start
cls
echo 请输入查询IP开始位置(例:10.0.0.1)
set /p ip_start=
if not defined ip_start goto proceed_start
:proceed_end
echo 请输入查询IP结束位置(例:10.0.0.255)
set /p ip_end=
if not defined ip_end goto proceed_end
echo.
echo 扫瞄 IP Address 请稍后......
echo.
::以下为副程式呼叫
::===========================================================================
::开始扫瞄初始区段规则
call :check_ip_rules
::===========================================================================
::判断ip规则等级
call :ip_rulse_scans
::===========================================================================

::依启动旗标执行功能
::当旗标ip_rules=1
if /i "%ip_rules%"=="0" goto :eof
if /i "%ip_rules%"=="1" for /f "tokens=2 delims=:" %%a in ('ping -n 1 -w 1 %ip_on1%.%ip_on2%.%ip_on3%.%ip_on4%^|find "TTL"') do (
       if /i TTL GEQ 0 (echo 设备 Reply form %ip_on1%.%ip_on2%.%ip_on3%.%ip_on4% 与本机电脑连线中)else echo echo 设备 Reply form %ip_on1%.%ip_on2%.%ip_on3%.%ip_on4% 与本机电脑已离线)
::当旗标ip_rules=2

::当旗标ip_rules=3

::当旗标ip_rules=4

::当旗标ip_rules=5

::当旗标ip_rules=6

::当旗标ip_rules=7
if /i "%ip_rules%"=="7" for /l %%a in (%ip_on4% 1 %ip_on5%) do (
       for /f "tokens=1 delims=:" %%a in ('ping -n 1 -w 1 %ip_on1%.%ip_on2%.%ip_on3%.%%a^|findstr "TTL"') do (
              if /i TTL GEQ 0 (echo 设备 %%a 与本机电脑连线中)else echo 设备 %%a 与本机电脑已离线))

::if /i "%ip_rules%"=="7" for /l %%a in (%ip_on4% 1 %ip_on5%) do (
::       for /f "tokens=1 delims=:" %%a in ('ping -n 1 -w 1 %ip_on1%.%ip_on2%.%ip_on3%.%%a^|findstr "TTL"') do (
::              if /i TTL GEQ 0 (echo %ip_on1%.%ip_on2%.%ip_on3%.%%a 连线中)else echo %ip_on1%.%ip_on2%.%ip_on3%.%%a 已离线))

::当旗标ip_rules=8
::if /i "%ip_rules%"=="8" for /f "tokens=1 delims=:" %%a in ('ping -n 1 -w 1 %ip_on1%.%ip_on2%.%ip_on3%.%ip_on4%^|find "TTL"') do 
::if /i TTL gtr 0 (echo %ip_on1%.%ip_on2%.%ip_on3%.%ip_on4% 连线中) else echo %ip_on1%.%ip_on2%.%ip_on3%.%ip_on4% 已离线

::for /l %%a in (%start_no4% 1 %end_no4%) do (
::ping -w 1 -n 1 %start_no1%.%start_no2%.%start_no3%.%%a)
::pause>unl
echo 扫瞄结束!!!
pause>unl
exit
::===========================================================================
::副程式:check_ip_rules开始
:check_ip_rules
::开始扫瞄初始区段规则
for /f "tokens=1-4 delims=." %%a in ("%ip_start%") do (
set start_no1=%%a
set start_no2=%%b
set start_no3=%%c
set start_no4=%%d
)
::判断输入规则是否大于255,若大于255则进位
if /i %start_no1% gtr 255 set /a start_no2=start_no2+1
if /i %start_no2% gtr 255 set /a start_no3=start_no3+1
if /i %start_no3% gtr 255 set /a start_no4=start_no4+1
if /i %start_no1% gtr 255 set /a start_no1=255
if /i %start_no2% gtr 255 set /a start_no2=255
if /i %start_no3% gtr 255 set /a start_no3=255
::判断输入末端规则是否大于255,若大于255则结束程序
if /i %start_no4% gtr 255 goto :error1
::判断末端规则是否小于等于0,若小于0则结束程序
if /i %start_no4% leq 0 goto :error1
::开始扫瞄结束区段规则
for /f "tokens=1-4 delims=." %%a in ("%ip_end%") do (
set end_no1=%%a
set end_no2=%%b
set end_no3=%%c
set end_no4=%%d
)
::判断输入规则是否大于255,若大于255则进位
if /i %end_no1% gtr 255 set /a end_no2=end_no2+1
if /i %end_no2% gtr 255 set /a end_no3=end_no3+1
if /i %end_no3% gtr 255 set /a end_no4=end_no4+1
if /i %end_no1% gtr 255 set /a end_no1=255
if /i %end_no2% gtr 255 set /a end_no2=255
if /i %end_no3% gtr 255 set /a end_no3=255
::判断输入末端规则是否大于255,若大于255则结束程序
if /i %end_no4% gtr 255 goto :error1
::判断末端规则是否小于等于0,若小于0则结束程序
if /i %end_no4% leq 0 goto :error1
::判断开始区段位置大于结束区段位置
if /i %start_no1% gtr %start_no1% goto error2
::字元补偿-加速用

goto :eof
::副程式:check_ip_rules结束
::===========================================================================

::判断ip规则等级
::两者ip相同
:ip_rulse_scans
:condition1-1
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set ip_on1=%start_no1%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set ip_on2=%start_no2%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set ip_on3=%start_no3%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set ip_on4=%start_no4%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% echo 符合condition1-1
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set /a ip_rules=1

:condition2-1
::classA-1
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set ip_on1=%start_no1%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set ip_on2=%start_no2%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set ip_on3=%start_no3%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set ip_on4=%start_no4%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set ip_on5=%end_no2%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% echo 符合condition2-1
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set /a ip_rules=2
if /i %start_no1%==%end_no1% if /i %start_no2% gtr %end_no2% if /i %start_no3%==%end_no3% if /i %start_no4%==%end_no4% set /a ip_rules=0 & goto error2
:condition2-2
::classA-2
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on1=%start_no1%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on2=%start_no2%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on3=%start_no3%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on4=%start_no4%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on5=%end_no2%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on6=%end_no3%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% echo 符合condition2-2
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set /a ip_rules=3

:condition2-3
::classA-3
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on1=%start_no1%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on2=%start_no2%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on3=%start_no3%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on4=%start_no4%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on5=%end_no2%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on6=%end_no3%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on7=%end_no4%
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% echo 符合condition2-3
if /i %start_no1%==%end_no1% if /i %start_no2% lss %end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set /a ip_rules=4

:condition3-1
::classB-1
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on1=%start_no1%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on2=%start_no2%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on3=%start_no3%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on4=%start_no4%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set ip_on5=%end_no3%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% echo 符合condition3-1
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4%==%end_no4% set /a ip_rules=5
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% gtr %end_no4% set /a ip_rules=5
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% gtr %end_no3% if /i %start_no4%==%end_no4% set /a ip_rules=0 & goto error2
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% gtr %end_no3% if /i %start_no4% gtr %end_no4% set /a ip_rules=0 & goto error2

:condition3-2
::classB-2
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on1=%start_no1%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on2=%start_no2%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on3=%start_no3%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on4=%start_no4%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on5=%end_no3%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set ip_on6=%end_no4%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% echo 符合condition3-2
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% lss %end_no3% if /i %start_no4% lss %end_no4% set /a ip_rules=6
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% gtr %end_no3% if /i %start_no4% lss %end_no4% set /a ip_rules=0 & goto error2
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3% gtr %end_no3% if /i %start_no4% gtr %end_no4% set /a ip_rules=0 & goto error2
:condition4-1
::classC
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4% lss %end_no4% set ip_on1=%start_no1%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4% lss %end_no4% set ip_on2=%start_no2%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4% lss %end_no4% set ip_on3=%start_no3%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4% lss %end_no4% set ip_on4=%start_no4%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4% lss %end_no4% set ip_on5=%end_no4%
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4% lss %end_no4% echo 符合condition4-1
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4% lss %end_no4% set /a ip_rules=7
if /i %start_no1%==%end_no1% if /i %start_no2%==%end_no2% if /i %start_no3%==%end_no3% if /i %start_no4% gtr %end_no4% set /a ip_rules=0 & goto error2


goto :eof
:error1
echo 输入之IP ADDRESS规则有误,请重新输入。
pause>unl
goto :eof
:error2
echo 开始区段不得大于结束区段,程序将关闭。
pause>unl
goto :eof


[ 此文章被adelin在2007-08-01 15:32重新编辑 ]


献花 x0 回到顶端 [1 楼] From:台湾 | Posted:2007-07-30 16:40 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.025448 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言