Configuring MSDE

I am not a database guru so the othet day I needed to edit the setup in my SBS MSDE database… I googled and found this. A supernice short run-through on how to configure MSDE.

I saved a copy incase it would disapear
———————————————————————————–

Introduction
This article describes how to configure the Microsoft MSDE database engine. Below you will find an overview of the topics.

What is MSDE?
Limitations
What you get
How to install and configure the MSDE
Arguments to the setup.exe file
Using the “setup.ini” file
Post reconfiguration
Configure the server
Configure the client
Fire it up!
How do I determine what version I am running?
Create and delete a database
How do I list all the databases on the system?
How do I detach a database from the system?
How do I attach a database to the system?
How do I list all tables in a database?
Database users
Add a new user with SQL authentication
With Win authentication
How to list all users and roles in a database
How to remove users from a database
Exit osql
What is MSDE?
MSDE is a limited version of the Microsoft SQL Server. In short, it is the Microsoft SQL Server 2000 database engine without any of the fancy UI tools, and with some limitations in the database size and the number of connections. The MSDE database is free, and can be distributed embedded in your own applications or as a small stand alone SQL server. It is ideal for small websites and small businesses with less than 25 simultaneous users. The database is limited to 2 GB of data storage space, but you can easily upgrade it to a full Microsoft SQL Server without any limitations. Among the choices are, a standard edition or an enterprise edition. An MSDE database is a good and affordable starting point for any business, organization or even home solutions. The database does not have to be installed on the hard drive on the deployment computer, but it could be running from a CD-ROM.

Limitations
There are some limitations to a MSDE database. You don’t get:

Failover clustering.
Log shipping.
Parallel DBCC.
Parallel create index.
Enhanced read ahead and scan.
Indexed views.
Federated database server.
System area network support (SAN).
Graphical DBA, and developer utilities and wizards.
Full-text search.
Analysis services.
OLAP partitions.
Partition wizard.
Linked OLAP cubes.
ROLAP dimension support.
HTTP Internet support.
Custom rollups.
Calculated Cells.
Write back to dimensions.
Very large dimension support.
Actions.
Real-time OLAP.
Distributed partition cubes.
Data mining.
English query.
What you get
This is what you get:

Maximum number of processors: 2 in NT/Win2000/XP/2003, 1 in Win98/ME.
Maximum physical memory: 2 GB.
Maximum user connections: 5 before the work load governor will limit the performance.
Maximum data storage: 2 GB.
Desktop embedded or network access.
Leading SQL database performance.
It’s free. =:-)
How to install and configure the MSDE
The MSDE can be downloaded from the Microsoft web site for free. Download the archive and uncompress it to a folder on your hard drive. There are four different ways to run the MSDE depending on how you want to access the database. They are all listed below.

You can configure the MSDE in three different ways:

Arguments to the setup.exe file.
Using the “setup.ini” file.
Post reconfiguration.
The four different running modes are:

Windows authentication without network access.
Windows authentication with network access.
Mixed Windows and SQL mode authentication without network access.
Mixed Windows and SQL mode authentication with network access.
Please use Windows authentication whenever possible. SQL mode will send the login and the password information over the network in plain text. This means it can be sniffed by intruders or hackers. Windows authentication uses SSPI which you can read more about on these web pages MSDN [1], and MSDN [2]. A default installation will disable the network access and uses the Windows authentication mode.

Before you start the installation of the MSDE, disable Norton Antivirus and the Internet Security Pack. You will enable it after the installation has completed. Norton Antivirus will not let you install the MSDE successfully, when enabled.

In all of our examples, we will be using “password” for the system administrator, and “myinstance” for the database instance.

Arguments to the setup.exe file
You can run configure the MSDE by giving arguments to the setup.exe file on a command prompt.

Windows authentication with network access.
Example 1 (Win access over a network).

In this example, we will be using Win authentication, because we do not want to send the username and password in plain text over the network. Only Windows applications and .NET applications can access the database. The application uses automatically the login name and password on the client computer to login to the MSDE.

C:…MSDE>Setup.exe DISABLENETWORKPROTOCOLS=0
              SAPWD=”password “INSTANCENAME=”myinstance”
Mixed Windows and SQL mode authentication with network access.
Example 2 (Java and Win access over a network):

In this example, we will be using the mixed mode authentication, because we want to access the database from both Windows applications and Java applications over a network. The username and password will be sent over the network in plain text.

C:…MSDE>Setup.exe DISABLENETWORKPROTOCOLS=0
      SAPWD=”password ” INSTANCENAME=”myinstance” SECURITYMODE=SQL
Mixed Windows and SQL mode authentication without network access.
Example 3 (Local Java and Win access only):

In this example, we will not be granting access from the network. Only local applications can access the database. We will be using mixed mode authentication for Java applications.

C:…MSDE>Setup.exe SAPWD=”password “INSTANCENAME=”myinstance” SECURITYMODE=SQL
Windows authentication without network access
Example 4 (Local Win access only):

In this example, we will not grant network access to the database. We will also only grant Win authentication access. This is the most secure setup, and should be used for embedded MSDE applications.

C:…MSDE>Setup.exe SAPWD=”password ” INSTANCENAME=”myinstance”
Using the “setup.ini” file
You will find a file called “setup.ini” in the MSDE folder, if you want to use a pre configured setup file. Please remember that anyone with read access to this file can see the system administrator password if this is an issue. The file looks like this:

[Options]
Here you will enter the configuration arguments.

Mixed Windows and SQL mode authentication with network access.
Example 1 (Java and Win access over a network):

In this example, we will be using mixed mode authentication, because we want to access the database from both Windows applications and Java applications over a network. The username and password will be sent over the network in plain text.

[Options]
DISABLENETWORKPROTOCOLS=0
SAPWD=”password “
INSTANCENAME=”myinstance”
SECURITYMODE=SQL
To install MSDE, run the “setup.exe” install application.

Windows authentication with network access.
Example 2 (Win access over a network):

In this example, we will be using Win authentication, because we do not want to send the username and password in plain text over the network. Only Windows applications and .NET applications can access the database. The application uses automatically the login name and password on the client computer to login to the MSDE.

[Optio
ns]
DISABLENETWORKPROTOCOLS=0
SAPWD=”password “
INSTANCENAME=”myinstance”
To install MSDE, run the “setup.exe” install application.

Mixed Windows and SQL mode authentication without network access.
Example 3 (Local Java and Win access only):

In this example, we will not be granting access from the network. Only local applications can access the database. We will be using mixed mode authentication for Java applications.

[Options]
SAPWD=”password “
INSTANCENAME=”myinstance”
SECURITYMODE=SQL
To install MSDE, run the “setup.exe” install application.

Windows authentication without network access
Example 4 (Local Win access only):

In this example, we will not grant network access to the database. We will also only grant Win authentication access. This is the most secure setup, and should be used for embedded MSDE applications.

[Options]
SAPWD=”password “
INSTANCENAME=”myinstance”
To install MSDE, run the “setup.exe” install application.

Post reconfiguration
It is possible to reconfigure the authentication mode for an already installed instance of the MSDE, through the registry. Stop the database instance in the Control Panel (“Administrative Tools” and “Services”). Open the “regedt32.exe”, and locate the “HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL ServermyinstanceMSSQLServer” and the key “LoginMode”. For Windows authentication, set this key to “1”; for SQL authentication, set this key to “0” (or “2”?). Restart the database instance in the Control Panel (“Administrative Tools” and “Services”).

Do you want to change the system administrator (sa user) password?
Login to the MSDE using the osql tool:

Using Win authentication:

C:> osql –E –S localhostmyinstance
1> use master
2> go
1> exec sp_password @old = null, @new = ‘newpassword’, @loginame = ‘sa’
2> go
Password changed.
1>quit
Using SQL authentication:

C:> osql –U sa –P password –S localhostmyinstance
1> use master
2> go
1> exec sp_password @old = null, @new = ‘newpassword’, @loginame = ‘sa’
2> go
Password changed.
1>quit
Configure the server:
Run the SQL Server network utility. Open a command prompt and type:

C:> svrnetcn.exe
Enable the “Named Pipes” protocol and the “TCP/IP” protocol. Click on “Properties” on the “TCP/IP” protocol. Here, you will configure the default port MSDE will be listening on if you want network access. Default is 1433.

Configure the client:
Run the SQL Server client network utility. Open a command prompt and type:

C:> cliconfg.exe
Enable the “Named Pipes” and the “TCP/IP” protocols. Click on “Properties” on the “TCP/IP” protocol. Here you configure the port number you found with the “svrnetcn.exe” utility. Default is 1433.

Add an alias for the “Named Pipes” and the “TCP/IP” under the “Alias” box. You will use an alias if you do not want to configure all applications to a specific configuration. The client just accesses the alias, and the client utility will map the request to the right configuration.

Fire it up!
Let’s start the MSDE. Open the Control Panel, the Administrative Tools and the “Services” utility. Find the instance “MSSQL$MYINSTANCE” in the list. Right click it, and choose “Start”. Startup type should be “Automatic”.

How do I determine what version I am running?
OK, the MSDE should now be up and running. Let’s test it. Run the osql tool.

C:> osql –E –S localhostmyinstance
1: select @@VERSION
2: go
3: quit

8.00.194 – MSDE 2000
8.00.384 – MSDE 2000 SP1
8.00.534 – MSDE 2000 SP2
8.00.760 – MSDE 2000 SP3
Create and delete a database
By default, the MSDE has four databases installed. These databases are:

Master – Contains all of the system meta-data, like login accounts, settings, and the location of the database files etc. Files: master.mdf, mastlog.ldf.
Tempdb – Contains work tables and temporary storage. All the data in this database will be deleted on disconnect. Files: tempdb.mdf, templog.ldf.
Model – This is a model of all databases on the system. It acts as a template for new databases. Files: model.mdl, modellog.ldf.
Msdb – Used for the SQL Server Agent to schedule jobs. Files: msdbdata.mdf, msdblog.ldf.
You should not use any of these databases for any application purposes. They are holy land as far as the applications know it. They are out of reach, simple as that. Create a new database to store your application data.

Let us create a database with the name “Books”. First of all, you must login as a system administrator (sa) or as a user with dbcreator privileges. Open the osql administration utility and login as system administrator.

C:> osql –U sa –P password –S localhostmyinstance
Or

C:> osql –E –S localhostmyinstance
Creating a simple database with the Model template:
1> use master
2:> go
1> CREATE DATABASE Books
2> go
The CREATE DATABASE process is allocating 0.63 MB on disk ‘Books’.
The CREATE DATABASE process is allocating 0.49 MB on disk ‘Books_log’.
Delete the Books database
1> use master
2:> go
1> DROP DATABASE Books
2> go
Deleting database file ‘C:Program FilesMicrosoft SQL
ServerMSSQL$MYINSTANCEDataBooks_log.LDF’.
Deleting database file ‘C:Program FilesMicrosoft SQL
ServerMSSQL$MYINSTANCEDataBooks.mdf’.
Creating a database specifying the file name
1> use master
2> go
1> CREATE DATABASE Books
2> ON
3> ( NAME = books_dat,
4> FILENAME = ‘D:Databasebooks.mdf’ )
5> go
The CREATE DATABASE process is allocating 0.63 MB on disk ‘books_dat’.
The CREATE DATABASE process is allocating 0.49 MB on disk ‘Books_log’.
NAME = Logical name used to specify the database in TSQL statements.
FILENAME = Physical location of the database on the hard drive.
Creating a database specifying the filename and the size
1> use master
2> go
1> CREATE DATABASE Books
2> ON
3> ( NAME = books_dat,
4> FILENAME = ‘D:Databasebooks.mdf’,
5> SIZE = 10,
6> MAXSIZE = 100,
7> FILEGROWTH = 5 )
8> go
The CREATE DATABASE process is allocating 10.00 MB on disk ‘books_dat’.
The CREATE DATABASE process is allocating 2.50 MB on disk ‘Books_log’.
NAME = Logical name used to specify the database in TSQL statements.
FILENAME = Physical location of the database on the hard drive.
SIZE = Initial file size.
MAXSIZE = The database maximum size.
FILEGROWTH = Increments of the database file. The DB file will grow with this size in MBs.
Creating a database specifying the filename, size, and logfile
1> use master
2> go
1> CREATE DATABASE Books
2> ON
3> ( NAME = Books_dat,
4> FILENAME = ‘D:Databasebooks.mdf’,
5> SIZE = 10,
6> MAXSIZE = 100,
7> FILEGROWTH = 5 )
8> LOG ON
9> ( NAME = ‘Books_log’,
10> FILENAME = ‘D:Databasebookslog.ldf’,
11> SIZE = 5,
12> MAXSIZE = 50,
13> FILEGROWTH = 2 )
14> go
The CREATE DATABASE process is allocating 10.00 MB on disk ‘Books_dat’.
The CREATE DATABASE process is allocating 5.00 MB on disk ‘Books_log’.
NAME = Logical name used to specify the log and the database in TSQL statements.
FILENAME = Physical location of the log file and the database on the hard drive.
SIZE = Initial file size.
MAXSIZE = The log and the database maximum size.
FILEGROWTH = Increments of the log and the database file. The DB file will grow with this size in MBs.
How do I list all the databases on the system?
If you want to list all the databases in the instance, please open the osql utility and do the following query:

C: >osql -E -S localhostmyinstance
1> use master
2> go
1> select name from sysdatabases
2> go
 name

————————————
master
tempdb
model
msdb
test
Products
 (6 rows affected)
In this example, I have created two databases: test and Products.

How do I detach a database from the system?
To detach a database called larsinge from the system, please do the following:

1> exec sp_detach_db ‘larsinge’
2> go
In this example, we detached a database called “larsinge”. The database can now be moved, backed-up, or you can do whatever you want to do with the files.

How do I attach a database to the system?
Simply do this to connect a database called larsinge:

1> exec sp_attach_db @dbname = ‘larsinge’,
2> @filename1 =
      ‘C:Program FilesMicrosoft SQL ServerMSSQL$LITBASEDatalarsinge.mdf’,
3> @filename2 =
      ‘C:Program FilesMicrosoft SQL ServerMSSQL$LITBASEDatalarsinge_log.LDF’
4> go
How do I list all tables in a database?
If you want to list all tables in an instance, please open the osql utility and do the following query:

C: >osql -E -S localhostmyinstance
1> use Products
2> go
1> select name from sysobjects where type = ‘U’
In this example, we list all tables in the Products database in the myinstance. Type ‘U’ means “User Table”. Please try to change type to “S” if you want to list out all System tables.

C: >osql -E -S localhostmyinstance
1> use Products
2> go
1> select name from sysobjects where type = ‘S’
Database users
Add and grant user access to the database.

Add a new user with SQL authentication:
This will add a new SQL login user ‘lars’ with the password ‘pass45’ and set the default database to ‘larsinge’. After creating the user, remember to grant access to the database and the tables for the user.

1> use master
2> go
1> EXEC sp_addlogin ‘lars’, ‘pass45’, ‘larsinge’
2> go
New login created.
Grant access to the database:

1> use larsinge
2> go
1> EXEC sp_grantdbaccess ‘lars’
2> go
Granted database access to ‘lars’.
1> grant all on table_name to lars
2> go
With Win authentication
Database name is ‘larsinge’, the Win auth user is ‘TARGUStestuser’:

1> use larsinge
2> go
1> exec sp_grantdbaccess ‘TARGUStestuser’
2> go
Granted database access to ‘TARGUStestuser’.
How to list all users and roles in a database?
Please open the osql utility, and do the following query to list all users in the Products database:

1> use Products
2> go
1> select name from sysusers
2> go
How to remove users from a database
This is how you revoke a user ‘lars’ access to the database ‘larsinge’.

1> use larsinge
2> go
1> exec sp_revokedbaccess ‘lars’
2> go
Exit osql

DHCP Server is not serving clients after SBS SP1 update

Q: My SBS servers DHCP server is not serving IP addresses to my clients since I updated to SBS SP1

A: Turns out that ISA 2004 protetects the internal firewall by default and that Internal network is not set up with the Broadcast address .255. This means that the DHCP requests never reaches the server.

Go to Configuration – Networks – Networks – Internal and edit it to include 255

Source

Manuyally registering proofing tools in Windows

1. Copy the .Dll and .Lex file for the language you want to add to c:Program FilesCommon FilesMicrosoft SharedProof

2. Add a registry hive pointing to the cossrect engine and lexicon for a specific language code:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINESOFTWAREMicrosoftShared ToolsProofing ToolsSpelling2068]

[HKEY_LOCAL_MACHINESOFTWAREMicrosoftShared ToolsProofing ToolsSpelling2068Normal]
“Dictionary”=”C:\PROGRA~1\COMMON~1\MICROS~1\Proof\NAME.LEX”
“Engine”=”C:\PROGRA~1\COMMON~1\MICROS~1\Proof\NAME.DLL”

[HKEY_LOCAL_MACHINESOFTWAREMicrosoftShared ToolsProofing ToolsSpelling2068NormalClients]
@=”C:\PROGRA~1\COMMON~1\MICROS~1\Proof\NAME.DLL”

 

Windows 2003 Server DNS fails to resolve some querys

When using Windows Server 2003 DNS some dns querys may fail because the Windows Server 2003 DNS Service is using Extension Mechanism which used UDP packets larger than 512 bytes. Some firewalls does not support this (so far I have seen this on Cisco PIX).

The Extension Mechanisms for DNS can be disabled using DNSCMD in Windows Support Tools

   dnscmd /config /enableednsprobes 0

Q832223: Some DNS Name Queries Are Unsuccessful After You Upgrade Your DNS Server to Windows Server 2003

More info on Extension Mechanisms for DNS

Using Extension Mechanisms for DNS (EDNS0)

Renaming Outlook System folders Part 2 (VBA Macro)

The Microsoft Outlook 2000 VBA macro, which can be used to change the Outlook default folder names.
Open the VBA macro with notepad and copy the code into the clipboard.

Open Outlook 2000 and select ‘Tools’, ‘Macros’, ‘Visual Basic Editor’ to open the Outlook 2000 VBA editor.
Expand the ‘ThisOutlookSession’ in the left-hand project window and paste the code into empty the right-hand window.

Select ‘Tools’, ‘References’ in the Outlook 2000 VBA editor and make sure ‘Microsoft CDO 1.21’ is selected.
Note that Outlook 2000 does not install CDO 1.21 by default. If you don’t see it in the Outlook VBA references
dialog CDO 1.21 might not be installed on your machine. If so, you have to run the Office 2000/Outlook 2000 setup
from CDO-ROM again and make sure CDO 1.21 is selected.

Close the Outlook 2000 VBA editor to save the changes.

To run the Outlook 2000 VBA macro open Outlook and chose ‘Tools’, ‘Macro’, ‘Macros’, select the desired macro and hit ‘Run’


Option Explicit

‘THIS CODE AND INFORMATION IS PROVIDED “AS IS” WITHOUT
‘WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
‘INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
‘OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
‘PURPOSE

‘——————————————————————————
‘ FILE DESCRIPTION: The macro ChangeFolder changes the name of all Outlook
‘ Default Folders to the language of your choice.
‘ AUTHOR: Siegfried Weber, http://www.cdolive.com
‘ VERSION INFO: Ver 1.0, 14 Jan 2000

‘ Copyright (c) 2000, free public use permitted with attribution
‘——————————————————————————

Sub ChangeFolder()

‘ Initialize error handling
On Error Resume Next

‘ MAPI property to access Drafts folder
Const CdoPR_Drafts = &H36D70102

‘Tyska
‘Const FOLDER_CALENDAR = “Kalender”
‘Const FOLDER_CONTACTS = “Kontakte”
‘Const FOLDER_DELETEDITEMS = “Gelöschte Objekte”
‘Const FOLDER_INBOX = “Posteingang”
‘Const FOLDER_JOURNAL = “Journal”
‘Const FOLDER_NOTES = “Notizen”
‘Const FOLDER_OUTBOX = “Postausgang”
‘Const FOLDER_SENTITEMS = “Gesendete Objekte”
‘Const FOLDER_TASKS = “Aufgaben”
‘Const FOLDER_DRAFTS = “Entwürfe”

‘Svenska
Const FOLDER_CALENDAR = “Kalender”
Const FOLDER_CONTACTS = “Kontakter”
Const FOLDER_DELETEDITEMS = “Borttaget”
Const FOLDER_INBOX = “Inkorgen”
Const FOLDER_JOURNAL = “Journal”
Const FOLDER_NOTES = “Anteckningar”
Const FOLDER_OUTBOX = “Utkorgen”
Const FOLDER_SENTITEMS = “Skickat”
Const FOLDER_TASKS = “Uppgifter”
Const FOLDER_DRAFTS = “Utkast”

‘Norska
‘Const FOLDER_CALENDAR = “Kalender”
‘Const FOLDER_CONTACTS = “Kontakter”
‘Const FOLDER_DELETEDITEMS = “Slettede Elementer”
‘Const FOLDER_INBOX = “Innboks”
‘Const FOLDER_JOURNAL = “Logg”
‘Const FOLDER_NOTES = “Notater”
‘Const FOLDER_OUTBOX = “Utboks”
‘Const FOLDER_SENTITEMS = “Sendte Elementer”
‘Const FOLDER_TASKS = “Oppgaver”
‘Const FOLDER_DRAFTS = “Kladd”

‘Danska
‘Const FOLDER_CALENDAR = “Kalender”
‘Const FOLDER_CONTACTS = “Kontakter”
‘Const FOLDER_DELETEDITEMS = “Borttaget”
‘Const FOLDER_INBOX = “Inkorgen”
‘Const FOLDER_JOURNAL = “Journal”
‘Const FOLDER_NOTES = “Anteckningar”
‘Const FOLDER_OUTBOX = “Utkorgen”
‘Const FOLDER_SENTITEMS = “Skickat”
‘Const FOLDER_TASKS = “Uppgifter”
‘Const FOLDER_DRAFTS = “Utkast”

‘Engelska
‘Const FOLDER_CALENDAR = “Calendar”
‘Const FOLDER_CONTACTS = “Contacts”
‘Const FOLDER_DELETEDITEMS = “Deleted Items”
‘Const FOLDER_INBOX = “Inbox”
‘Const FOLDER_JOURNAL = “Journal”
‘Const FOLDER_NOTES = “Notes”
‘Const FOLDER_OUTBOX = “Outbox”
‘Const FOLDER_SENTITEMS = “Sent Items”
‘Const FOLDER_TASKS = “Tasks”
‘Const FOLDER_DRAFTS = “Drafts”

‘ Declare variables
Dim objSession As MAPI.Session
Dim objFolder As MAPI.Folder
Dim objInboxFolder As MAPI.Folder
Dim objFields As MAPI.Fields
Dim strEntryID As String

‘ Initialize variables
Set objSession = Nothing
Set objFolder = Nothing
Set objInboxFolder = Nothing
Set objFields = Nothing

‘ Create CDO session and logon
Set objSession = New MAPI.Session

‘ Check if CDO session created
If Not objSession Is Nothing Then

‘ CDO session logon
Err.Clear
objSession.Logon “”, “”, ShowDialog:=False, NewSession:=False

‘ Check if CDO session logon successful
If Err.Number = 0 Then

‘ Get default calendar folder
Err.Clear
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderCalendar)

‘ Check if folder found
If Err.Number = 0 Then

‘ Rename folder
objFolder.Name = FOLDER_CALENDAR

‘ Save changes
Err.Clear
objFolder.Update MakePermanent:=True, RefreshObject:=True

‘ Check for possible errors
If Err.Number <> 0 Then

‘ Cannot change folder name, display error message
MsgBox “Could not change Outlook default folder name for: “ & objFolder.Name _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
End If

‘ Get default contact folder
Err.Clear
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderContacts)

‘ Check if folder found
If Err.Number = 0 Then

‘ Rename folder
objFolder.Name = FOLDER_CONTACTS

‘ Save changes
Err.Clear
objFolder.Update MakePermanent:=True, RefreshObject:=True

‘ Check for possible errors
If Err.Number <> 0 Then

‘ Cannot change folder name, display error message
MsgBox “Could not change Outlook default folder name for: “ & objFolder.Name _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
End If

‘ Get default deleted items folder
Err.Clear
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderDeletedItems)

‘ Check if folder found
If Err.Number = 0 Then

‘ Rename folder
objFolder.Name = FOLDER_DELETEDITEMS

‘ Save change
s

Err.Clear
objFolder.Update MakePermanent:=True, RefreshObject:=True

‘ Check for possible errors
If Err.Number <> 0 Then

‘ Cannot change folder name, display error message
MsgBox “Could not change Outlook default folder name for: “ & objFolder.Name _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
End If

‘ Get default inbox folder
Err.Clear
Set objFolder = objSession.Inbox

‘ Check if folder found
If Err.Number = 0 Then

‘ Rename folder
objFolder.Name = FOLDER_INBOX

‘ Save changes
Err.Clear
objFolder.Update MakePermanent:=True, RefreshObject:=True

‘ Check for possible errors
If Err.Number <> 0 Then

‘ Cannot change folder name, display error message
MsgBox “Could not change Outlook default folder name for: “ & objFolder.Name _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
End If

‘ Get default journal folder
Err.Clear
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderJournal)

‘ Check if folder found
If Err.Number = 0 Then

‘ Rename folder
objFolder.Name = FOLDER_JOURNAL

‘ Save changes
Err.Clear
objFolder.Update MakePermanent:=True, RefreshObject:=True

‘ Check for possible errors
If Err.Number <> 0 Then

‘ Cannot change folder name, display error message
MsgBox “Could not change Outlook default folder name for: “ & objFolder.Name _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
End If

‘ Get default notes folder
Err.Clear
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderNotes)

‘ Check if folder found
If Err.Number = 0 Then

‘ Rename folder
objFolder.Name = FOLDER_NOTES

‘ Save changes
Err.Clear
objFolder.Update MakePermanent:=True, RefreshObject:=True

‘ Check for possible errors
If Err.Number <> 0 Then

‘ Cannot change folder name, display error message
MsgBox “Could not change Outlook default folder name for: “ & objFolder.Name _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
End If

‘ Get default outbox folder
Err.Clear
Set objFolder = objSession.Outbox

‘ Check if folder found
If Err.Number = 0 Then

‘ Rename folder
objFolder.Name = FOLDER_OUTBOX

‘ Save changes
Err.Clear
objFolder.Update MakePermanent:=True, RefreshObject:=True

‘ Check for possible errors
If Err.Number <> 0 Then

‘ Cannot change folder name, display error message
MsgBox “Could not change Outlook default folder name for: “ & objFolder.Name _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
End If

‘ Get default sent items folder
Err.Clear
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderSentItems)

‘ Check if folder found
If Err.Number = 0 Then

‘ Rename folder
objFolder.Name = FOLDER_SENTITEMS

‘ Save changes
Err.Clear
objFolder.Update MakePermanent:=True, RefreshObject:=True

‘ Check for possible errors
If Err.Number <> 0 Then

‘ Cannot change folder name, display error message
MsgBox “Could not change Outlook default folder name for: “ & objFolder.Name _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
End If

‘ Get default tasks folder
Err.Clear
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderTasks)

‘ Check if folder found
If Err.Number = 0 Then

‘ Rename folder
objFolder.Name = FOLDER_TASKS

‘ Save changes
Err.Clear
objFolder.Update MakePermanent:=True, RefreshObject:=True

‘ Check for possible errors
If Err.Number <> 0 Then

‘ Cannot change folder name, display error message
MsgBox “Could not change Outlook default folder name for: “ & objFolder.Name _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
End If

‘ Get default inbox folder
Set objInboxFolder = objSession.Inbox

‘ Get fields collection of inbox folder
Set objFields = objInboxFolder.Fields

‘ Get drafts folder entry ID
strEntryID = objFields.Item(CdoPR_Drafts).Value

‘ Check if entry ID found
Set objFolder = Nothing
If Trim(strEntryID) <> “” Then

‘ Get default drafts folder
Set objFolder = objSession.GetFolder(strEntryID, objInboxFolder.StoreID)
End If

‘ Check if folder found
If Not objFolder Is Nothing Then

‘ Rename folder
objFolder.Name = FOLDER_DRAFTS

‘ Save changes
Err.Clear
objFolder.Update MakePermanent:=True, RefreshObject:=True

‘ Check for possible errors
If Err.Number <> 0 Then

‘ Cannot change folder name, display error message
MsgBox “Could not change Outlook default folder name for: “ & objFolder.Name _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
End If

‘ Logoff
objSession.Logoff
MsgBox “Finished changing Outlook default folder names.”, vbInformation
Else

‘ Cannot logon to CDO session, display error message
MsgBox “Could not create CDO Session. Please check if CDO 1.x is installed on this computer.” _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If
Else

‘ Cannot create CDO session, display error message
MsgBox “Could not create CDO Session. Please check if CDO 1.x is installed on this computer.” _
& Chr(13) & Err.Number & Chr(13) & Err.Description, vbCritical
End If

‘ Tidy up
Set objSession = Nothing
Set objFolder = Nothing
Set objInboxFolder = Nothing
Set objFields = Nothing
End Sub

Renaming Outlook System folders Part 1 (VB Script)

‘ RenFldr – Rename Outlook “Special Folders”
‘ (c) Neo (n…@mvps.org)
‘ 11.11.2000, v.1.0
‘ 11.06.2002, v.1.1

‘ Test System
‘ Windows Script Host v.
‘ VBScript v.
‘ Outlook 2000 (SR1a)
‘ Windows 2000 (SP1)

‘ Change Log
‘ 11.11.2000 – Creation Date
‘ 11.06.2002 – Added support drafts folder

Const olFolderDeletedItems = 3
Const olFolderOutbox = 4
Const olFolderSentItems = 5
Const olFolderInbox = 6
Const olFolderCalendar = 9
Const olFolderContacts = 10
Const olFolderJournal = 11
Const olFolderNotes = 12
Const olFolderTasks = 13
Const olFolderDrafts = 16

Dim Engine
Dim Outlook
Dim Folder

Select Case UCase(Right(WScript.FullName, 11))
Case “WSCRIPT.EXE”
Engine = “W”
Case “CSCRIPT.EXE”
Engine = “C”
End Select

Set Args = WScript.Arguments

If Args.Count = 0 Then
DisplayHelp()
WScript.Quit
End If

If Args.Item(0) = “-?” Or Args.Item(0) = “/?” Or Args.item(0) = “?” Then
DisplayHelp()
WScript.Quit
End If

If Args.Count <> 2 Then
DisplayHelp()
WScript.Quit
End If

Set Outlook = CreateObject(“Outlook.Application”)
Set Folder = Nothing

Select Case UCase(Args.Item(0))
Case “CALENDAR”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderCalendar)
Case “INBOX”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderInbox)
Case “OUTBOX”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderOutbox)
Case “SENTITEMS”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderSentItems)
Case “DELETEDITEMS”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderDeletedItems)
Case “CONTACTS”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderContacts)
Case “JOURNAL”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderJournal)
Case “NOTES”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderNotes)
Case “TASKS”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderTasks)
Case “DRAFTS”
Set Folder = Outlook.GetNameSpace(“MAPI”).GetDefaultFolder(olFolderDrafts)
Case Else
DisplayHelp()
End Select

If Folder Is Nothing Then
WScript.Quit
End If

Folder.Name = Args.Item(1)

Set Folder = Nothing
Set Outlook = Nothing

Sub DisplayHelp()
If Engine = “W” Then
MsgBox “RenFldr:” & vbCRLF &_
” Change Name of Default Folders” & vbCRLF & vbCRLF &_
“Usage: RenFldr Folder NewName” & vbCRLF & vbCRLF &_
” Supported values for Folder:” & vbCRLF &_
” Inbox” & vbCRLF &_
” Outbox” & vbCRLF &_
” Calendar” & vbCRLF &_
” SentItems” & vbCRLF &_
” DeletedItems” & vbCRLF &_
” Contacts” & vbCRLF &_
” Journal” & vbCRLF &_
” Notes” & vbCRLF &_
” Tasks” & vbCRLF &_
” Drafts”
Else
WScript.StdOut.WriteLine “RenFldr:”
WScript.StdOut.WriteLine ” Change Name of Default Folders” & vbCRLF
WScript.StdOut.WriteLine “Usage: RenFldr Folder NewName” & vbCRLF
WScript.StdOut.WriteLine ” Supported values for Folder:”
WScript.StdOut.WriteLine ” Inbox”
WScript.StdOut.WriteLine ” Outbox”
WScript.StdOut.WriteLine ” Calendar”
WScript.StdOut.WriteLine ” SentItems”
WScript.StdOut.WriteLine ” DeletedItems”
WScript.StdOut.WriteLine ” Contacts”
WScript.StdOut.WriteLine ” Journal”
WScript.StdOut.WriteLine ” Notes”
WScript.StdOut.WriteLine ” Tasks”
WScript.StdOut.WriteLine ” Drafts”
End If
End Sub