|
-
Aug 14th, 2008, 05:34 PM
#3
Thread Starter
New Member
Re: VBS to detect what version of Outlook and Overwrite a file
Ok, here is what I have thus far. Works great until it goes to copy the new file, and then it just kinda stops. Not sure why. It isnt coping over the file.
Code:
' Macro_update.vbs
'
'
Dim WSHShell, checkdspKey, outook2000ver, outlook2002ver, outlook2003ver, outlook2007ver, otherVersion
Set objShell = WScript.CreateObject("WScript.Shell")
Const OverwriteExisting = True
' If any regread fails, continue executing
On Error Resume Next
' Check to see if this script has the block key
' If the block key is entered, end script
RegKey = objShell.regread("HKCU\Software\DarksideProductions\Outlook\filedoesnotexist")
' set the checkdspKey variable based on the regread outcome
if Err.Number then
checkdspKey = "1"
else checkdspKey = "2"
end if
' Log that nothing will be changed
if checkdspKey = "2" then
WScript.echo "****DSP Block Key detected, script exiting****"
end if
' Quit the script
if checkdspkey = "2" then
WScript.Quit
end if
' Change / add the key depending upon the Outlook version detected
' Outlook 2003 Script
RegKey = objShell.regread("HKCU\Software\Microsoft\Office\11.0\Outlook\Options\General\Security Zone")
if Err.Number then
outlook2003ver = "0"
else
outlook2003ver = "1"
Dim FSO2k3
Set FSO2k3 = CreateObject("Scripting.FileSystemObject")
FSO2k3.CopyFile "\\server1\Autoresponses\Macro\2003\normal.dot", "%USERPROFILE%\Application Data\Microsoft\Templates\"
end if
On Error Resume Next
' Outlook 2002 Script
RegKey = objShell.regread("HKCU\Software\Microsoft\Office\10.0\Outlook\Options\General\Security Zone")
if Err.Number then
outlook2002ver = "0"
else
outlook2002ver = "1"
Dim FSO2k2
Set FSO2k2 = CreateObject("Scripting.FileSystemObject")
FSO2k2.CopyFile "\\server1\Autoresponses\Macro\2002\normal.dot", "%USERPROFILE%\Application Data\Microsoft\Templates\"
end if
On Error Resume Next
' Outlook 2000 Script
' For Outlook 2k, we check a different key for the presence of Outlook due to inconsistent registry
' appearance on the terminal servers.
RegKey = objShell.regread("HKCU\Software\Microsoft\Office\9.0\Outlook\Options\MSHTML\International\LastIEVersion")
if Err.Number then
outlook2000ver = "0"
else
outlook2000ver = "1"
Dim FSO2k
Set FSO2k = CreateObject("Scripting.FileSystemObject")
FSO2k.CopyFile "\\server1\Autoresponses\Macro\2000\normal.dot", "%USERPROFILE%\Application Data\Microsoft\Templates\"
end if
' If none of the three keys are found, log the following info and quit
otherVersion = "0"
if outlook2007ver = "1" then
otherVersion= "1"
end if
if outlook2003ver = "1" then
otherVersion = "1"
end if
if outlook2002ver = "1" then
otherVersion = "1"
end if
if outlook2000ver = "1" then
otherVersion = "1"
end if
if otherVersion = "0" then
WScript.echo "Client is not running Outlook 2000, 2002, 2003, 2007, or has not setup email yet."
WScript.Quit
end if
' log the key update and apparent Outlook version
if outlook2000ver = "1" then
WScript.echo "Client appears to be running Outlook 2000"
end if
if outlook2002ver = "1" then
WScript.echo "Client appears to be running Outlook 2002"
end if
if outlook2003ver = "1" then
WScript.echo "Client appears to be running Outlook 2003"
end if
if checkdspKey = "1" then
WScript.echo "Updated Macros"
end if
WScript.Quit(0)
Last edited by daffed13; Aug 15th, 2008 at 12:15 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|