--- gui.c.old	2006-11-05 00:35:52.000000000 +0000
+++ gui.c	2006-11-28 18:20:30.000000000 +0000
@@ -216,13 +216,27 @@
 	VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 	GetVersionEx(&VerInfo);
 	GetOSName(VerInfo, OSName);
+	
+	{ // Set Current Directory
+		TCHAR path[MAX_PATH];
+		if(GetModuleFileName(NULL, path, MAX_PATH))
+		{
+			char *pname = strrchr(path, '\\');
+			if(pname != NULL)
+			{
+				*pname = '\0';
+				SetCurrentDirectory(path);
+			}
+		}
+	}
+	
 	if (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) 
 	{
 		SC_HANDLE hService, hSCManager = OpenSCManager(NULL, NULL, GENERIC_EXECUTE);
+		StartServiceCtrlDispatcher(DispatchTable); 
 		if ((hService = OpenService(hSCManager, "UnrealIRCd", GENERIC_EXECUTE))) 
 		{
 			int save_err = 0;
-			StartServiceCtrlDispatcher(DispatchTable); 
 			if (GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT)
 			{ 
 				SERVICE_STATUS status;
