Jul 24 2008

ASP.NET tab forces restart of IIS

This has been a pain in the back side for some time (well at least for me), whilst there are few scripts out their that clam to solve this problem, I have personally found this is not true there is still IIS restarts.

And sure you could directly go and edit the metabase.xml, But that leaves to many rooms for mistakes, and you can also go and change the version of  .Net by going into the application configuration within IIS and then manually change the version their.



Both above ways will change the .NET without a restart, but that’s just too much work, I stumbled across Jerry Orman Blog post on this very subject

Jerry Orman : ASP.NET tab forces restart of W3SVC

Jerry has created a very nifty VBS to over come this pain in the but IIS restart, and it works

Cheers Jerry.

Jul 18 2008

Which web site belongs to the w3wp process


Really the better way of saying it is which ‘application pool’ belongs to the w3wp process, anyway there are a few ways to get the app pool names for each PID.

Microsoft were nice enough to provide a VBS that will display this information for us, you can find this in the system32 folder of your 2003 server – ‘IISapp.vbs’

I wrote a 2 second batch file that will get the PID’s and the app pools for you


   1: REM: this will find all of the W3WP PID against each app pool
   2: REM: enter to continue
   3: Pause
   4: c:
   5: cd windows
   6: cd system32
   7: iisapp.vbs 
   9: Pause

Read more about this below:

Which w3wp.exe process belongs to which App Pool in IIS6 – Scott Forsyth’s Blog

Jul 16 2008

CRM 4: Event Log MSCRMKeyGenerator

Your here because you got an CRM 4 error ‘unable to load’

Below the event log you should be seeing:

Event Type:    Error
Event Source:    MSCRMKeyGenerator
Event Category:    None
Event ID:    18949
Date:        16/07/2008
Time:        10:47:26 AM
User:        N/A
Computer:    ETDC2
Current active key (KeyType : CrmWRPCTokenKey) is expired.  This can indicate that a key is not being regenerated properly.  Current Active Key : CrmKey(Id:7ca9e53d-db38-dd11-9398-003048781151, ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmWRPCTokenKey, Expired:True, ValidOn:06/12/2008 23:56:58, ExpiresOn:07/15/2008 23:56:58, CreatedOn:06/12/2008 23:56:58, CreatedBy:NT AUTHORITY\NETWORK SERVICE.  Key Setting :

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.


easy fix

Start the CRM Asynchronous service as below:


Jul 9 2008

Complete Guide to SQL 2005 mirroring using the GUI

Well it has occurred to me that there are no real guides to setting up mirroring that deal with what errors you could, or more like you will run into whilst setting up a mirror.


Ok for this example I am going to setup a ‘High safety with automatic failover’ this particular mirror uses a Principle server, failover server and a witness server, so for this example you will need 3 servers (you could get a way with 2 as the witness could be the failover, but best to have 3)

So first thing is first the prerequisites.

3 SQL 2005 server’s

Service Packs installed
at least SP1 applied, if this is not applied you will get an error saying that this feature is not enabled, you can enable this feature, however I recommend rather then playing with the startup values you patch your MSSQL server to the current SP for SQL.

MSSQL Service
You must have all three SQL servers using an account that has network access, by default most of us will have used the local system account, which in this case is not going to work, you will get this obscure error message when trying to start the mirror.


 All databases in FULL recovery Mode
both the mirror and the failover database both need to be in a Full recovery mode, if not you will get the below error

‘the database cannot be mirrored because it does not use the full recovery model’


If you get this, right click on your database and go to ‘properties’ then to ‘options’ you can change the mode their.


OK, Now your ready to start getting the mirror together

first thing is first, take a full backup of your database that you want to start mirroring, move this backup to a share or somewhere that your failover server can restore the database from.

Now using the same name of the database on the Principle server, create a database, then restore the database backup, make sure when restoring the database you are using the NORECOVERY method

You could use this TSQL to create and complete your database restore:

restore databasename from disk backup location and name with replace, NORECOVERY


restore mydatabase from disk d:\SQL_backups\mydatabase.bak with replace, NORECOVERY

Ok now you should have a database on your failover server and it should be in a ‘restoring’ state, if you are not seeing this then refresh your databases, if you still don’t see then then you probably missed the NORECOVERY part, go back and do this again with NORECOVERY applied.

we are halfway there, all you need to do now is again create another backup on the principle server, but this time it must be a transactional backup. So once again create a new transactional backup, place the backup in a place where the fail over server can restore the database from, and then perform your restore again using the NORECOVERY method.

or do this from TSQL

restore mydatabase from disk  d:\SQL_backups\mydatabaseTRANSACTIONAL.TRN with NORECOVERY

Once again you will have a database that should be still in a restoring state.

If this step is missed or you restore an older TRN log file, then you can expect to get the following error when trying to create the mirror :

‘the mirror database …., has insufficient transaction log data to preserver log backup chain of the principle  database.


Now we are ready to start the mirroring!
right click on the principle database mirror, choose tasks followed by Mirror


You will be prompted with the following:

Click on security in the top right side


Yes we want to include a witness server, (in this case we are doing the high availability so we need a witness server for it to work)


Make sure all three are ticked


This is where we get to set the port that the mirroring is going to be using to connect to each other, and the endpoint name. I have accepted defaults, but before excepting default ports ensure that all of your servers can talk to each other throughout that port best way to test would be

telnet servername 5022

do this for all combinations so from:

principle to witness
principle to fail over

failover to principle
failover to witness

witness to Failover
witness to principle

If you can make successful connections to each then you are good to go.


Once you have run through the 3 database servers you will be prompted with the below screen:

Here if they are all on the same network and using integrated (AD) authentication which recommenced) then you may skip this, otherwise you will be required to enter in valid credentials


You should come to this screen after the review screen, if you have failed on one of the servers, then read the error and correct the problem (these errors are generally helpful ones :) )



Now start you mirror!


Other problems you may run into:

If you tried to start your mirror, and you get an error ‘one or more of the servers network addresses lacks a fully qualified domain name’  that’s an easy one, you must edit the server so it has a FQDN like server.domain.com if your DNS is being painful add it to the host file of the server you are setting the mirror up on.



That should be enough to get your mirror up and runn



Stay tuned more on mirroring coming soon

as promised a new more in depth look auto- failover of SQL Mirroring, it can be found here, SQL 2005 Mirroring – Automatic Failover

Jul 8 2008

Windows Command Line Find and replace – Made easy

I finally found a great little application that does a find and replace on a particular file or file type, then replacing it with a string, of your choice. It also looks in sub directory, whilst there are many grep’s out there most are GUI for windows or pay for items that run command line… I like free better, don’t you?

And yes SED could do it, as could a few other apps, but why write something when this  can be done so much easier?

the small app is called FART, yes that’s right FART!

Here are the options FART provides

Find And Replace Text  v1.99b                         by Lionello Lunesu

Usage: FART [options] [--] <wildcard>[,...] [find_string] [replace_string]

-h, –help          Show this help message (ignores other options)
-q, –quiet         Suppress output to stdio / stderr
-V, –verbose       Show more information
-r, –recursive     Process sub-folders recursively
-c, –count         Only show filenames, match counts and totals
-i, –ignore-case   Case insensitive text comparison
-v, –invert        Print lines NOT containing the find string
-n, –line-number   Print line number before each line (1-based)
-w, –word          Match whole word (uses C syntax, like grep)
-f, –filename      Find (and replace) filename instead of contents
-B, –binary        Also search (and replace) in binary files (CAUTION)
-C, –c-style       Allow C-style extended characters (\xFF\t\n\r\\ etc.)
     –cvs           Skip cvs dirs; execute “cvs edit” before changing files
     –svn           Skip svn dirs
     –remove        Remove all occurences of the find_string
-a, –adapt         Adapt the case of replace_string to found string
-b, –backup        Make a backup of each changed file
-p, –preview       Do not change the files but print the changes


As an example

fart -c -r -i -p *.config databaseserver1 databaseserver2

this will look for all config files in a sub directory then looking for the databaseserver1 string within the .config file and then changing it to databaseserver2, If you notice i have a -p which means it wont actually change anything because this is a preview, showing you how many strings it found within each .config file.

Download FART here


Jun 17 2008

Search All tables within a Database


I came across this very useful script the other day, it simply creates a Stored Procedure, where it allows you to search all columns within every table of a selected database, While it was said to be tested on SQL 7 and 2000 I can confirm it works on SQL 2005 just as well :)

   1: CREATE PROC SearchAllTables
   2: (
   3:     @SearchStr nvarchar(100)
   4: )
   5: AS
   6: BEGIN
   8:     -- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.
   9:     -- Purpose: To search all columns of all tables for a given search string
  10:     -- Written by: Narayana Vyas Kondreddi
  11:     -- Site: http://vyaskn.tripod.com
  12:     -- Tested on: SQL Server 7.0 and SQL Server 2000
  13:     -- Date modified: 28th July 2002 22:50 GMT
  16:     CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))
  18:     SET NOCOUNT ON
  20:     DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
  21:     SET  @TableName = ''
  22:     SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')
  24:     WHILE @TableName IS NOT NULL
  25:     BEGIN
  26:         SET @ColumnName = ''
  27:         SET @TableName = 
  28:         (
  31:             WHERE         TABLE_TYPE = 'BASE TABLE'
  32:                 AND    QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
  33:                 AND    OBJECTPROPERTY(
  34:                         OBJECT_ID(
  35:                             QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
  36:                              ), 'IsMSShipped'
  37:                                ) = 0
  38:         )
  40:         WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
  41:         BEGIN
  42:             SET @ColumnName =
  43:             (
  44:                 SELECT MIN(QUOTENAME(COLUMN_NAME))
  45:                 FROM     INFORMATION_SCHEMA.COLUMNS
  46:                 WHERE         TABLE_SCHEMA    = PARSENAME(@TableName, 2)
  47:                     AND    TABLE_NAME    = PARSENAME(@TableName, 1)
  48:                     AND    DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
  49:                     AND    QUOTENAME(COLUMN_NAME) > @ColumnName
  50:             )
  52:             IF @ColumnName IS NOT NULL
  53:             BEGIN
  54:                 INSERT INTO #Results
  55:                 EXEC
  56:                 (
  57:                     'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630) 
  58:                     FROM ' + @TableName + ' (NOLOCK) ' +
  59:                     ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
  60:                 )
  61:             END
  62:         END    
  63:     END
  65:     SELECT ColumnName, ColumnValue FROM #Results
  66: END


Once you have ran the SP, you must call it, then within the ‘ ‘ you can type what you are looking for, the execute and wait!

EXEC SearchAllTables ‘your query here’


the original script was Found at :


Jun 3 2008

Configuring the CRM v4 outlook Client Fails

A while ago we rolled out CRM v4, however we only started to roll out the client for V4 only very recently, When trying to roll out the application I was getting an odd error message.


“The configuration wizard cannot connect to the Microsoft CRM server. This might indicate that the server is down”


The server was clearly not down, as the web interface was fine. It turned out to be a mix of IIS and database related issues.

Lets look at IIS:

if you are running a host header with CRM, simple answer don’t. Use DNS rather then then setting a host header on CRM, this will cause you all sorts of grief (this was explained in a previous post also). Also within regards to the Host header, Also I find not setting a host header will cause problems when installing the client.

So you ask what can I do… easy have a host header of the server name, ensure you are NOT using ALL UNASSIGENED, but use a specific IP (the primary for the adaptor if more then one)

Then do a IISRESET.

So that’s IIS sorted.

So lets look at SQL server.

Now if you are like us we moved our front end server (IIS) a few times, which is fine but the CRM database makes reference to the web server and the port it runs on, so you must change these references also.

Backup your database before using this script.

Update DeploymentProperties SET NVarCharColumn = '<serverName>:<port>' WHERE ColumnName = 'AsyncSdkRootDomain'
Update DeploymentProperties SET NvarCharColumn = '<serverName>:<port>' WHERE ColumnName = 'ADSdkRootDomain' 
Update DeploymentProperties SET NvarCharColumn = '<serverName>:<port>' WHERE ColumnName = 'ADWebApplicationRootDomain' 

NOTE: replace the ‘<serverName>:<port>’ with your IIS servername and the Port it runs on. (STD install port for CRM is 5555)

May 28 2008

VISTA: Remote Registry off by default

Just a quick one today, as you probably have worked out the remote registry is turned off by default within windows vista making Sys Admin job’s a little harder to install third party applications through a central location.

I was unable to find a script that would start the service and then create the service as automatic.

whilst the starting the service is easy enough, I wanted the service to be automatic, so that way we only have to run the script on all VISTA machines just once, there is no point running it every time on boot up when  we can avoid slowing the system down a little.

Here is the script (.BAT) it will set the service to automatic (on XP and VISTA)


reg import "\\DOMAINCONTROLLER NAME HERE\SYSVOL\DOMAIN\scripts\remotereg.reg"
net start "remote registry"

NOTE: I did not use the delay start because my Group Policy applies to both XP and Vista, this would cause a conflict as the delay start is not an option in XP, I would recommend the delayed start method if you have isolated just your VISTA machines in a group policy


Above you can see it is calling a .reg file this is the contents of the reg, copy and save it as a .reg file also

Windows Registry Editor Version 5.00

May 21 2008

AD Based Outlook Email Signature for 2003 and 2007 Part 3 – Removing the Reply / forward signature

To even further requests for the script to be modified, where the script only add the signature to the new message, rather then the standard of adding to both new message and reply / Forward messages.

If you have run the original script previously  you will have find that just running the new script I am about to paste below is useless and it does not get rid of the reply / Forward. Well that’s because the script has added this into the registry, so we must remove this setting. to do this you can run the below batch file:

reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A66760000001" /v "Reply-Forward Signature" /f 
reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A66760000002" /v "Reply-Forward Signature" /f 
reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A66760000003" /v "Reply-Forward Signature" /f 

copy the above text and save it as a .bat file.

NOTE: for the 2003 users if you look in your registry and you are finding that you don’t have the 3rd registry hive, that’s OK, I have included it for 07 users as well, it will do no harm if you don’t have it.

OK now that you have run the above batch file you can open outlook and you will see you no longer have a reply / forward but you will still have your signature on a new message. So we are half way there, all we need to do is now modify the original script so that the reply / forward is not added to the registry again.

see below:

' VBScript: <Signatures.vbs>
' AUTHOR: Peter Aarts
' Contact Info: peter.aarts@l1.nl
' Version 2.04
' Date: January 20, 2006
' Modified by Brad Marsh on 21 may 08
' added 2007 support and remove reply / forward signatures
' Tested on both 03 and 07 outlook
' contact: gentex@tpg.com.au
'Option Explicit
On Error Resume Next
Dim qQuery, objSysInfo, objuser
Dim FullName, EMail, Title, PhoneNumber, MobileNumber, FaxNumber, OfficeLocation, Department
Dim web_address, FolderLocation, HTMFileString, StreetAddress, Town, State, Company
Dim ZipCode, PostOfficeBox, UserDataPath
' Read LDAP(Active Directory) information to asigns the user's info to variables.
Set objSysInfo = CreateObject("ADSystemInfo")
qQuery = "LDAP://" & objSysInfo.Username
Set objuser = GetObject(qQuery)
FullName = objuser.displayname
EMail = objuser.mail
Company = objuser.Company
Title = objuser.title
PhoneNumber = objuser.TelephoneNumber
FaxNumber = objuser.FaxNumber
OfficeLocation = objuser.physicalDeliveryOfficeName
StreetAddress = objuser.streetaddress
PostofficeBox = objuser.postofficebox
Department = objUser.Department
ZipCode = objuser.postalcode
Town = objuser.l
MobileNumber = objuser.TelephoneMobile
web_address = "http://www.elcom.com.au"
' This section creates the signature files names and locations.
' Corrects Outlook signature folder location. Just to make sure that
' Outlook is using the purposed folder defined with variable : FolderLocation
' Example is based on Dutch version.
' Changing this in a production enviremont might create extra work
' all employees are missing their old signatures
Dim objShell, RegKey, RegKey07, RegKeyParm
Set objShell = CreateObject("WScript.Shell")
RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\General"
RegKey07 = "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\General"
RegKey07 = RegKey07 & "\Signatures"
RegKey = RegKey & "\Signatures"
objShell.RegWrite RegKey , "AD_elcom"
objShell.RegWrite RegKey07 , "AD_elcom"
UserDataPath = ObjShell.ExpandEnvironmentStrings("%appdata%")
FolderLocation = UserDataPath &"\Microsoft\AD_elcom\"
HTMFileString = FolderLocation & "Elcom.htm"
' This section disables the change of the signature by the user.
'objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\NewSignature" , "L1-Handtekening"
'objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\ReplySignature" , "L1-Handtekening"
'objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EnableLogging" , "0", "REG_DWORD"
' This section checks if the signature directory exits and if not creates one.
Dim objFS1
Set objFS1 = CreateObject("Scripting.FileSystemObject")
If (objFS1.FolderExists(FolderLocation)) Then
Call objFS1.CreateFolder(FolderLocation)
End if
' The next section builds the signature file
Dim objFSO
Dim objFile,afile
Dim aQuote
aQuote = chr(34)
' This section builds the HTML file version
Set objFSO = CreateObject("Scripting.FileSystemObject")
' This section deletes to other signatures.
' These signatures are automaticly created by Outlook 2003.
Set AFile = objFSO.GetFile(Folderlocation&"Elcom.rtf")
Set AFile = objFSO.GetFile(Folderlocation&"Elcom.txt")
Set objFile = objFSO.CreateTextFile(HTMFileString,True)
Set objFile = objFSO.OpenTextFile(HTMFileString, 2)
objfile.write "<!DOCTYPE HTML PUBLIC " & aQuote & "-//W3C//DTD HTML 4.0 Transitional//EN" & aQuote & ">" & vbCrLf
objfile.write "<HTML><HEAD><TITLE>Microsoft Office Outlook Signature</TITLE>" & vbCrLf
objfile.write "<META http-equiv=Content-Type content=" & aQuote & "text/html; charset=windows-1252" & aQuote & ">" & vbCrLf
objfile.write "<META content=" & aQuote & "MSHTML 6.00.3790.186" & aQuote & " name=GENERATOR></HEAD>" & vbCrLf
objfile.write "<body>" & vbCrLf
objfile.write "    <head> <style type=text/css>" & vbCrLf
objfile.write "}" & vbCrLf
objfile.write "<!DOCTYPE HTML PUBLIC " & aQuote & "-//W3C//DTD HTML 4.0 Transitional//EN" & aQuote & ">" & vbCrLf
objfile.write "<HTML><HEAD><TITLE>Microsoft Office Outlook Signature</TITLE>" & vbCrLf
ite "<META http-equiv=Content-Type content=" & aQuote & "text/html; charset=windows-1252" & aQuote & ">" & vbCrLf
objfile.write "<META content=" & aQuote & "MSHTML 6.00.3790.186" & aQuote & " name=GENERATOR></HEAD>" & vbCrLf
objfile.write "<body>" & vbCrLf
objfile.write "    <head> <style type=text/css>" & vbCrLf
objfile.write "}" & vbCrLf
objfile.write ".style4 {" & vbCrLf
objfile.write "    text-decoration: none;" & vbCrLf
objfile.write "    color: #696969;" & vbCrLf
objfile.write "    font-family: Verdana;" & vbCrLf
objfile.write "}" & vbCrLf
objfile.write "</style></head>" & vbCrLf
objfile.write "<font color=696969 face=Verdana>" & vbCrLf
objfile.write "<b> <span style='font-size: 10pt;'> "& FullName & "</span> </b> " & vbCrLf
objfile.write "<span style='color: #FF0000;font-size: 10pt;font-weight: bold;'>|</span> " & vbCrLf
objfile.write "<a href=mailto:" & Email &" span style='font-size: 8pt;text-decoration: none;color: #696969;' > <span style='font-size: 8pt;text-decoration: none;color: #696969;'>" & Email &" </span></a>" & vbCrLf
objfile.write "<br>" & vbCrLf
objfile.write "<span style='font-size: 8pt;color: #696969;font-weight: bold;'>" & title & " </span> <br>" & vbCrLf
objfile.write "<br>" & vbCrLf
objfile.write "<span style='font-size: 7.5pt;color: #696969;'>"& Company & " </span>" & vbCrLf
objfile.write "<span style='color: #FF0000; font-size: 7.5pt;'>|</span> <span style='font-size: 7.5pt;color: #696969;'>Australian Technology Park</span> " & vbCrLf
objfile.write "<span style='color: #FF0000; font-size: 7.5pt;'>| </span> " & vbCrLf
objfile.write "<span style='font-size: 7.5pt;color: #696969;'> Sydney </span><br>" & vbCrLf
objfile.write "<span style='color: #FF0000; font-size: 7.5pt;'>t</span><span style='font-size: 7.5pt;color: #696969;'> +612 " & PhoneNumber &"</span><span style='color: #FF0000; font-size: 7.5pt;'>&nbsp;&nbsp;f</span><span style='font-size: 7.5pt;color: #696969;'> +612 9209 4423</span>" & vbCrLf
objfile.write "<span style='color: #FF0000; font-size: 7.5pt;'>| </span>" & vbCrLf
objfile.write "<span style='font-size: 7.5pt;color: #696969;'> <a href=http://www.elcom.com.au><span class=style4>www.elcom.com.au</a></span> </span><br>" & vbCrLf
objfile.write "<br>" & vbCrLf
objfile.write "<A href=http://www.elcom.com.au/> <img src=http://www.elcom.com.au/images/elcom-logo-web-175x70.gif height=70 width=175 border=0></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & vbCrLf
objfile.write "<img src=http://www.elcom.com.au/images/mspartner.gif height=55 width=265><br>" & vbCrLf
objfile.write "<br>" & vbCrLf
objfile.write "<span style='font-size: 7.5pt;color: #696969;'>Please consider </span><span style='font-size: 7.5pt;color: #00b050;'>our environment</span><span style='font-size: 7.5pt;color: #696969;'> before printing this email.</span></font><font color=696969 size=1 face=Verdana><br> " & vbCrLf
objfile.write "<hr size=1 font align=left width=465 color=696969><span style='font-size: 7.5pt;color: #696969;'>This email is intended for the intended recipients(s) and may contain confidential information. <br> Reproduction, dissemination or distribution of this message is prohibited unless authorised by the sender.<br> If you are not the intended recipient, please notify the sender immediately and you must not read,<br> keep, use, disclose, copy or distribute this email without the sender's prior permission.<br> The views expressed by the sender are not necessarily those of Elcom Technology Pty Ltd</font></span></font>" & vbCrLf
' ===========================
' This section readsout the current Outlook profile and then sets the name of the default Signature
' ===========================
' Use this version to set all accounts
' in the default mail profile
' to use a previously created signature
Call SetDefaultSignature("Elcom","")
' Use this version (and comment the other) to
' modify a named profile.
'Call SetDefaultSignature _
' ("Signature Name", "Profile Name")
Sub SetDefaultSignature(strSigName, strProfile)
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
If Not IsOutlookRunning Then
Set objreg = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows NT\" & _
"CurrentVersion\Windows " & _
"Messaging Subsystem\Profiles\"
' get default profile name if none specified
If strProfile = "" Then
objreg.GetStringValue HKEY_CURRENT_USER, _
strKeyPath, "DefaultProfile", strProfile
End If
' build array from signature name
myArray = StringToByteArray(strSigName, True)
strKeyPath = strKeyPath & strProfile & _
objreg.EnumKey HKEY_CURRENT_USER, strKeyPath, _
For Each subkey In arrProfileKeys
strsubkeypath = strKeyPath & "\" & subkey
objreg.SetBinaryValue HKEY_CURRENT_USER, _
strsubkeypath, "New Signature", myArray
'strMsg1 = "Completed Signature Sucssefully"
'MsgBox strMsg1
strMsg = "Please shut down Outlook before " & _
"running this script."
MsgBox strMsg, vbExclamation, "SetDefaultSignature"
End If
End Sub
Function IsOutlookRunning()
strComputer = "."
strQuery = "Select * from Win32_Process " & _
"Where Name = 'Outlook.exe'"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery(strQuery)
For Each objProcess In colProcesses
If UCase(objProcess.Name) = "OUTLOOK.EXE" Then
IsOutlookRunning = True
IsOutlookRunning = False
End If
End Function
Public Function StringToByteArray _
(Data, NeedNullTerminator)
Dim strAll
strAll = StringToHex4(Data)
If NeedNullTerminator Then
strAll = strAll & "0000"
End If
intLen = Len(strAll) \ 2
ReDim arr(intLen - 1)
For i = 1 To Len(strAll) \ 2
arr(i - 1) = CByte _
("&H" & Mid(strAll, (2 * i) - 1, 2))
StringToByteArray = arr
End Function
Public Function StringToHex4(Data)
' Input: normal text
' Output: four-character string for each character,
' e.g. "3204" for lower-case Russian B,
' "6500" for ASCII e
' Output: correct characters
' needs to reverse order of bytes from 0432
Dim strAll
For i = 1 To Len(Data)
' get the four-character hex for each character
strChar = Mid(Data, i, 1)
strTemp = Right("00" & Hex(AscW(strChar)), 4)
strAll = strAll & Right(strTemp, 2) & Left(strTemp, 2)
StringToHex4 = strAll
End Function


that’s it you can re-run the above script, of course modify the HTML and other parts to suite you (see here how to change the script)and you should have only signatures on a new message permanently.



May 19 2008

Vista Activation: 0×8007232B – DNS name does not exist

If you have installed a Volume licence version on Vista business / Enterprise, you may get the below error message when trying to active the product


a pretty useless error message, but it does have a very easy fix, simply go to computer and then ‘change Product Key’ enter in the same product key that you had previously used for the VISTA installation.

That’s it it should activate within seconds.