搜档网
当前位置:搜档网 › outlook自动配置脚本

outlook自动配置脚本

'===================================================================
'
' 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

相关主题