Solved

Changing the Microsoft Exchange Server name Automatically

Posted on 2004-03-29
3
1,732 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
3 Comments
 
LVL 2

Accepted Solution

by:
wescojohn earned 250 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now