Solved

Changing the Microsoft Exchange Server name Automatically

Posted on 2004-03-29
3
1,764 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

738 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