阿笨狗(jspadmin)网络日志

个人网络日志,网络、技术、思想、生活、札记……

« 宝宝可以自己翻身了如何备份和还原 Outlook Express 数据 »

Outlook客户端自动配置脚本

目前有这样一个客户需求:在一期项目当中,客户端不加入域,但要求配置并使用客户端的Outlook。由于客户端数量较大(大约1200个),手

工配置太繁琐,工作量也非常巨大,因此写了一个Outlook客户端配置脚本,顺便提供大家一个参考。

  1、我们需要有一个Outlook配置文件(PRF文件),此配置文件的生成及具体参数请参考http://technet.microsoft.com/zh-

cn/library/cc179062(TechNet.10).aspx

  2、执行写好的脚本将配置文件导入并配置Outlook客户端即可(PRF配置文件需要与脚本在同一目录,并在脚本中指定PRF文件的名称)

  3、脚本内容

'===================================================================
'
' VBScript Source File
'
' NAME: Billy Fu
'
' AUTHOR: Outlook配置脚本-Outlook_Profile_Config
'
' DATE : 2008/7/14
'
'
'===================================================================
ON ERROR RESUME NEXT

Const OFFICE11_PATH = "C:\Program Files\Microsoft Office\Office11"
Const OFFICE12_PATH = "C:\Program Files\Microsoft Office\Office12"

dim strUserName
dim intOfficeVer
dim strOfficePath

strUserName = ""
intOfficeVer = ""
strOfficePath = ""

strUserName = InputBox("请输入您在域中的用户帐号,格式如:BillyFu","Outlook配置脚本")
If strUserName = "" Then
Msgbox "取消Outlook配置!"
Else
while intOfficeVer = ""
intOfficeVer = InputBox("请输入您本机安装的Outlook版本号:2007或2003,其他版本不支持","Outlook配置脚本","2003")

if intOfficeVer = "" then
Msgbox "Outlook 设置取消!"
intOfficeVer = "error"
else
if intOfficeVer <> "2007" And intOfficeVer <> "2003" Then
intOfficeVer = ""
else
if intOfficeVer = "2007" then
strOfficePath = OFFICE12_PATH
else
strOfficePath = OFFICE11_PATH
end if
strOfficePath = InputBox("请确定您本机安装的Outlook路径","Outlook配置脚本",strOfficePath)
Call InstallOutlookProfile
end if
end if
Wend
End If


sub InstallOutlookProfile


ModifyPRFFile

Dim WshShell
Set WshShell = Wscript.CreateObject("Wscript.Shell")


Dim strPath
strPath = WScript.ScriptFullName
strPath = Left(strPath, InstrRev(strPath, "\")) & "OutlookProfile1.PRF" '指定Outlook PRF 配置文件

dim strCmd
strCmd = """" & strOfficePath & "\outlook.exe"" /importprf """ & strPath & """"
WshShell.Run strCmd, 1, false
end sub

sub ModifyPRFFile

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim strCon


Dim fso, f1, f2, ts
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.GetFile("OutlookProfile.PRF") '设置从Outlook配置文件中读取信息
Set ts = f1.OpenAsTextStream(ForReading, TristateUseDefault)
strCon = ts.ReadAll
ts.close

strCon = Replace(strCon,"%UserName%",strUserName)


fso.CreateTextFile "OutlookProfile1.PRF"
Set f2 = fso.GetFile("OutlookProfile1.PRF") '创建一个配置文件
Set ts = f2.OpenAsTextStream(ForWriting, TristateUseDefault)
ts.Write strCon
ts.Close

end sub

sub Err

if err <> 0 then
Wscript.echo "Outlook配置脚本出错,自动退出!"
Err.Clear
end if

end sub Share
  • quote 1.licufa
  • 你的博客很不错,我做了一个将1000个博客链接拼成一幅大图的博客拼图网,其中就收录了你的博客,欢迎你来找找看,也欢迎交换链接。我的博客,面谱 www.mianpu1000.com
  • 2009-3-12 17:17:04 回复该留言

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Walle Build 100427

Auto Publisher Copyright 1999-2011 www.pifoo.com. Some Rights Reserved.
闽ICP备05035478号