![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-12 23:20 |
共 47,811 主题排行 / 349,897 发帖 / 今日 0 篇 / 48,256 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 怎样把批处理中的文件路径放到配置文件中读取? |
| 可打印版本 652 / 3 |
| 第1楼 boy | 发表于 2010-01-08 09:04 |
| 初级用户 发帖 29 积分 29 | |
|
怎样把批处理中的文件路径放到配置文件中读取? 我目前的批处理是这样的:
@echo off set date=%~1 ping /n 83 127.1>nul IF EXIST k:\public_html\website\nul rd k:\public_html\website /s/q start /b xcopy /s/r/y/h/c D:\Inetpub\wwwroot\whbcn\public_html\*.* k:\public_html\>D:\Inetpub\wwwroot\whbcn\website_design\Log\updateServerB\%date%.log goto :eof exit 我想将里面几个路径放到一个配置文件中,而不是象现在一样写死在批处理里面. 比如配置文件fileConfig.ini内容: BServerPathWeb=k:\public_html\website AServerPath=D:\Inetpub\wwwroot\whbcn\public_html BServerPath=k:\public_html updateServerBLogPath=D:\Inetpub\wwwroot\whbcn\website_design\Log\updateServerB 我的批处理该怎样改进一下啊?多谢了! |
|
| 第2楼 bat-zw | 发表于 2010-01-08 09:30 |
| 金牌会员 发帖 1,276 积分 3,105 | |
|
[ Last edited by bat-zw on 2010-1-8 at 10:43 ] |
|
| 第3楼 boy | 发表于 2010-01-08 10:28 |
| 初级用户 发帖 29 积分 29 | |
|
现在在运行的时候,会提示?:
"目标k:\public_html\>D:\Inetpub\wwwroot\whbcn\website_design\Log\updateServerB\%date%.log 是文件名还是目录名 <F = 文件. D = 目录>?" 怎样去掉提示啊?而且现在并没有把旧的文件夹k:\public_html\website删掉,也没有拷贝路径D:\Inetpub\wwwroot\whbcn\public_html\下的所有文件到k:\public_html\下. 修改后的文件: @echo off for /f "delims=" %%a in (pathConfig.ini) do set "%%a" set "dates=%~1"&rem ping /n 83 127.1>nul if exist "%BServerPathWeb%\nul" rd /s/q "%BServerPathWeb%" start /b xcopy /s/r/y/h/c "%AServerPath%\*.*" "%BServerPath%\>%updateServerBLogPath%\%dates%.log" goto :eof exit 谢谢! [ Last edited by boy on 2010-1-8 at 10:33 ] |
|
| 第4楼 boy | 发表于 2010-01-08 12:06 |
| 初级用户 发帖 29 积分 29 | |
|
搞定!~ 多谢bat-zw
|
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |