中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 高手进:自动替换地址簿的批处理,寻找优化
作者:
标题: 高手进:自动替换地址簿的批处理,寻找优化 上一主题 | 下一主题
secowu
初级用户





积分 201
发帖 92
注册 2005-12-28
状态 离线
『楼 主』:  高手进:自动替换地址簿的批处理,寻找优化

搞了个自动替换OE地址簿的批处理,感觉好多废话。

麻烦高手修改下,并优化,看看有没有可以让它支持前面定义的那些程序?

谢谢
@echo off
@set MO="Microsoft Outlook"
@set HO="Hotmail"
@set WL="Windows Live Mail"
@set WM="Windows Mail"
@set OE="Outlook Express"
@for /f "tokens=2*" %%i in ('reg query HKLM\SOFTWARE\Clients\Mail /v "" ^| findstr /i /c:"REG_SZ"') do ( set client=%%j)
@if  not "%client%" == %OE% (goto NS) else (goto OE)
@if [%client%]==[] (goto CU) else (goto LM)
:CU
@for /f "tokens=2*" %%i in ('reg query HKCU\SOFTWARE\Clients\Mail /v "" ^| findstr /i /c:"REG_SZ"') do ( set client=%%j)
@if  not "%client%" == %OE% (goto NS) else (goto OE)
@if [%client%]==[] (goto Crazy) else (goto lm)
:Crazy
(
echo ---------------------------
echo   无法检测到邮件默认程序
echo     程序即将退出......
echo ---------------------------
echo   如有疑问请联系:SECO
)|msg %username%  /time 6
exit
:LM
@if  not "%client%" == %OE% (goto NS) else (goto OE)
:NS
(
echo -------------------------------------
echo 检测到邮件默认程序:
echo     %client%!
echo     本程序目前仅支持 Outlook Express!
echo     程序即将退出......
echo -------------------------------------
echo 如有疑问请联系:SECO
)|msg %username%  /time 6
exit
:OE
set mydate=%Date:~0,14%%time:~0,2%%time:~3,2%%time:~6,2%
@for /f "tokens=2*" %%i in ('reg query "HKCU\Software\microsoft\wab\wab4\wab file name" /v "" ^| findstr /i /c:"REG_SZ"') do ( set wab=%%j)
set mydate=%Date:~0,14%%time:~0,2%%time:~3,2%%time:~6,2%
@if  exist "%USERPROFILE%\Application Data\Microsoft\Address Book\%USERNAME%.wab" goto Ori
@if  exist "%wab%" goto Cus
@goto error
:Ori
@msg %username% /time 3  "检测到地址簿:"%USERPROFILE%\Application Data\Microsoft\Address Book\%USERNAME%.wab"!即将更新..."
@copy /y "%USERPROFILE%\Application Data\Microsoft\Address Book\%USERNAME%.wab" "%systemdrive%\%mydate%.wab" >nul
@copy /y "%USERPROFILE%\Application Data\Microsoft\Address Book\%USERNAME%.wab" "%USERPROFILE%\Application Data\Microsoft\Address Book\%mydate%.wab" >nul
@ if exist "%systemdrive%\%mydate%.wab"  msg %username% /time 3 "地址簿备份成功一次:"%mydate%.wab
@ if exist "%USERPROFILE%\Application Data\Microsoft\Address Book\%mydate%.wab"  msg %username% /time 3 "地址簿备份成功二次:"%mydate%.wab
::@ if not exist "%systemdrive%\%mydate%.wab" goto fail
@ if not exist "%USERPROFILE%\Application Data\Microsoft\Address Book\%mydate%.wab" goto fail
@copy /y "Update.wab" "%USERPROFILE%\Application Data\Microsoft\Address Book\%USERNAME%.wab" >nul
@ if not exist "%USERPROFILE%\Application Data\Microsoft\Address Book\%USERNAME%.wab" goto sorry
goto OK
:Cus
@msg %username% /time 3  "检测到地址簿:%wab%!即将更新..."
@copy /y "%wab%" "%systemdrive%\%mydate%.wab" >nul
@copy /y "Update.wab" "%wab%" >nul
goto OK
:OK
@msg %username% /time 8  "替换成功, 请退出重开 Outlook Express 以生效!先前如有导出专属WAB文档的,请重新导入即可。 "
exit
:error
@msg %username% /time 5  "程序未检测到 Outlook Express 地址簿,更新无法继续! "
exit
@color 0a
:fail
@msg %username% /time 5 "备份地址簿失败,请联系管理员。程序即将中止并退出。"
exit
:sorry
@copy "%USERPROFILE%\Application Data\Microsoft\Address Book\%mydate%.wab" "%USERPROFILE%\Application Data\Microsoft\Address Book\%USERNAME%.wab"
@if not exist "%USERPROFILE%\Application Data\Microsoft\Address Book\%mydate%.wab" goto sorry
@msg %username% /time 5 "备份地址簿失败,程序已经恢复原先地址簿。"
exit


2009-6-13 00:50
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: