Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Changing the Microsoft Exchange Server name Automatically

Posted on 2004-03-29
3
Medium Priority
?
1,793 Views
Last Modified: 2012-08-14
Hello.

I am looking to change the Exchange Server name automatically, probably using VBA code. I am talking about when you:

1. right-click on your desktop "Outlook" icon, select properties
2. select "Microsoft Exchange Server" from the "Services" tab and click on properties
3. changing the "Microsoft Exchange Server" name on the top line

Can anyone help?

Thx,

Clayton
0
Comment
Question by:Snakie1066
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
wescojohn earned 1000 total points
ID: 10717964
'This will enumerate through the registry and change the Exchange Server data for a user

On Error Resume Next

const HKEY_CURRENT_USER = &H80000001

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_

".\root\default:StdRegProv")

Set StdOut = WScript.StdOut

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"

oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys
            expStrKeyPath = strKeyPath & subkey & "\"
            oReg.EnumKey HKEY_CURRENT_USER, expStrKeyPath, arr2SubKeys

            For Each subkey2 In arr2SubKeys

                        expStrKeyPath2 = expStrKeyPath & subkey2
            If Right(expStrKeyPath2,32) = "13dbb0c8aa05101a9bb000aa002fc45a" Then

            Dim Path
            Path = "HKCU\" & expStrKeyPath2 & "\"
Set WSHShell = Wscript.CreateObject("WScript.Shell")
ServerName = "NewServerName"
OldServer = "OldServerName"

'this fills the sub key with the value of new server and specifies that it is a regular string

KeyExist = WSHShell.RegRead(path & "001e6608")

 If KeyExist = ServerName Then

 Wscript.Quit

 ElseIf Ucase(KeyExist) <> OldServerName Then

 MsgBox "Unexpected Exchange Settings.  Please contact the help desk"

 Wscript.Quit

 ElseIf Ucase(KeyExist) = OldServerName Then

            WSHShell.RegWrite path & "001e6608",ServerName,"REG_SZ"

            WSHShell.RegWrite path & "001e6602",ServerName,"REG_SZ"

 End If


If err then

 msgbox "Error Encountered Changing Exchange Server Name" & vbCrLf & "Please contact the help desk."

else

 Wscript.Quit

End if
Wscript.Quit
            End If
            Next
Next
0
 

Author Comment

by:Snakie1066
ID: 10718299
Perfect. This answer was just what I was looking for. Thanks very much.
0
 
LVL 23

Expert Comment

by:Justin Durrant
ID: 13793936
I tried to run this and I get this error:

C:\>cscript update.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\update.vbs(6, 1) Microsoft VBScript compilation error: Syntax error


C:\>


Code:



On Error Resume Next

const HKEY_CURRENT_USER = &H80000001

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_

".\root\default:StdRegProv")

Set StdOut = WScript.StdOut

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"

oReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys
            expStrKeyPath = strKeyPath & subkey & "\"
            oReg.EnumKey HKEY_CURRENT_USER, expStrKeyPath, arr2SubKeys

            For Each subkey2 In arr2SubKeys

                        expStrKeyPath2 = expStrKeyPath & subkey2
            If Right(expStrKeyPath2,32) = "13dbb0c8aa05101a9bb000aa002fc45a" Then

            Dim Path
            Path = "HKCU\" & expStrKeyPath2 & "\"
Set WSHShell = Wscript.CreateObject("WScript.Shell")
ServerName = "NFDNT004"
OldServer = "SVMAILNF"

'this fills the sub key with the value of new server and specifies that it is a regular string

KeyExist = WSHShell.RegRead(path & "001e6608")

 If KeyExist = ServerName Then

 Wscript.Quit

 ElseIf Ucase(KeyExist) <> OldServerName Then

 MsgBox "Unexpected Exchange Settings.  Please contact Justin or John"

 Wscript.Quit

 ElseIf Ucase(KeyExist) = OldServerName Then

            WSHShell.RegWrite path & "001e6608",ServerName,"REG_SZ"

            WSHShell.RegWrite path & "001e6602",ServerName,"REG_SZ"

 End If


If err then

 msgbox "Error Encountered Changing Exchange Server Name" & vbCrLf & "Please contact the help desk."

else

 Wscript.Quit

End if
Wscript.Quit
            End If
            Next
Next


Any idas?
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
By default Outlook 2016 displays only one time zone in the Calendar. The following article explains how to display two time zones in one calendar view.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question