diff --git a/contrib/pg_autovacuum/README.pg_autovacuum b/contrib/pg_autovacuum/README.pg_autovacuum
index 764ae3f79fb3739220f6aaa04fb3ea2703b6dfff..3cb633000e63171be9e3b57881f2b66553fc4f38 100644
--- a/contrib/pg_autovacuum/README.pg_autovacuum
+++ b/contrib/pg_autovacuum/README.pg_autovacuum
@@ -55,6 +55,15 @@ postmasters on a particular host, you will need multiple pg_autovacuum
 instances, and they have no way, at present, to coordinate between one
 another to ensure that they do not concurrently vacuum big tables.
 
+When installed as a service under Windows, there is currently no way to
+know the name of the PostgreSQL server service (if there even is one)
+so it is not possible to specify a startup dependency. It is therefore
+possible for pg_autovacuum to start before the server.
+
+When installed as a service under Windows, if the -P option is used to
+specify the connection password, this option (and the password) is 
+stored in plain text in the registry.
+
 TODO:
 -----
 
@@ -117,7 +126,9 @@ pg_autovacuum has the following optional arguments:
 -L log file: Name of file to which output is submitted, otherwise STDERR
 -U username: Username pg_autovacuum will use to connect with, if not
    specified the current username is used.
--P password: Password pg_autovacuum will use to connect with.
+-P password: Password pg_autovacuum will use to connect with. *WARNING*
+   When installed as a Windows Service, this option will be stored in plain
+   text in the registry.
 -H host: host name or IP to connect to.
 -p port: port used for connection.
 -h help: list of command line options.
@@ -133,6 +144,19 @@ the time of writing they are:
 -s 300 (5 minutes)
 -S 2
 
+The following arguments are used on Windows only:
+
+-I Install the executable as a Windows service. Other appropriate command
+   line options will be stored in the registry and passed to the service 
+   at startup. *WARNING* This includes the connection password which will 
+   be stored in plain text.
+	     
+-N service user: Name of the Windows user account under which the service
+   will run.
+   
+-W service password: The password for the service account.
+
+-R Uninstall pg_autovacuum as a service.
 
 Vacuum and Analyze:
 -------------------
diff --git a/contrib/pg_autovacuum/pg_autovacuum.c b/contrib/pg_autovacuum/pg_autovacuum.c
index 021e4ae1f549d22391ea54bb31ebf2ad2b994476..addd66b4c30a804ea0c578accb479c33a880c49b 100644
--- a/contrib/pg_autovacuum/pg_autovacuum.c
+++ b/contrib/pg_autovacuum/pg_autovacuum.c
@@ -25,12 +25,8 @@ log_entry(const char *logentry, int level)
 {
 	/*
 	 * Note: Under Windows we dump the log entries to the normal
-	 * stderr/logfile
-	 */
-
-	/*
-	 * as well, otherwise it can be a pain to debug service install
-	 * failures etc.
+	 * stderr/logfile as well, otherwise it can be a pain to debug 
+	 * service install failures etc.
 	 */
 
 	time_t		curtime;
@@ -117,7 +113,7 @@ log_entry(const char *logentry, int level)
 		}
 	}
 
-	ReportEvent(evtHandle, elevel, 0, 1, NULL, 1, 0, &logentry, NULL);
+	ReportEvent(evtHandle, elevel, 0, 0, NULL, 1, 0, &logentry, NULL);
 #endif
 }
 
@@ -1219,7 +1215,7 @@ InstallService()
 	if (args->user)
 		sprintf(szCommand, "%s -U %s", szCommand, args->user);
 	if (args->password)
-		sprintf(szCommand, "%s -p %s", szCommand, args->password);
+		sprintf(szCommand, "%s -P %s", szCommand, args->password);
 	if (args->logfile)
 		sprintf(szCommand, "%s -L %s", szCommand, args->logfile);
 	if (args->sleep_base_value != (int) SLEEPBASEVALUE)
@@ -1249,21 +1245,12 @@ InstallService()
 	if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hk, NULL))
 		return -5;
 
-	/* TODO Create an actual message file! */
-	/* Message count */
-	sprintf(szMsgDLL, "pgmessages.dll");
+	/* TODO Try to find pgevent.dll, rather than hope it's in the path. ! */
+	/* Message DLL */
+	sprintf(szMsgDLL, "pgevent.dll");
 	if (RegSetValueEx(hk, "EventMessageFile", 0, REG_EXPAND_SZ, (LPBYTE) szMsgDLL, (DWORD) strlen(szMsgDLL) + 1))
 		return -6;
 
-	/* Category message file */
-	if (RegSetValueEx(hk, "CategoryMessageFile", 0, REG_EXPAND_SZ, (LPBYTE) szMsgDLL, (DWORD) strlen(szMsgDLL) + 1))
-		return -7;
-
-	/* Category message count */
-	dwData = 0;
-	if (RegSetValueEx(hk, "CategoryCount", 0, REG_DWORD, (LPBYTE) & dwData, sizeof(DWORD)))
-		return -8;
-
 	/* Set the event types supported */
 	dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE | EVENTLOG_SUCCESS;
 	if (RegSetValueEx(hk, "TypesSupported", 0, REG_DWORD, (LPBYTE) & dwData, sizeof(DWORD)))