Solved

Changing the Microsoft Exchange Server name Automatically

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
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 …
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…

832 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