diff --git a/VersionOne.ServiceHost/Program.cs b/VersionOne.ServiceHost/Program.cs index 814a19c..74034a7 100644 --- a/VersionOne.ServiceHost/Program.cs +++ b/VersionOne.ServiceHost/Program.cs @@ -1,4 +1,3 @@ -/*(c) Copyright 2012, VersionOne, Inc. All rights reserved. (c)*/ using System; using System.IO; using System.Reflection; @@ -32,11 +31,11 @@ private static void UninstallService() { } catch { } if(ServiceUtil.UnInstallService(Config.ShortName)) - Console.WriteLine("Service Uninstall Successful"); + Console.WriteLine("Service uninstall successful"); else - Console.WriteLine("Service Uninstall Failed"); + Console.WriteLine("Service uninstall failed"); } catch(Exception ex) { - throw new ApplicationException("Uninstall Failed - " + ex.Message); + throw new ApplicationException("Uninstall failed - " + ex.Message); } } @@ -44,16 +43,16 @@ private static void InstallService() { try { if(ServiceUtil.InstallService("\"" + Assembly.GetEntryAssembly().Location + "\" --service", Config.ShortName, Config.LongName, ServiceUtil.LocalService, null)) { - Console.WriteLine("Service Installation Successful"); + Console.WriteLine("Service installation successful!"); } else { - Console.WriteLine("Service Installation Failed"); + Console.WriteLine("Service installation failed"); } try { ServiceUtil.StartService(Config.ShortName); } catch { } } catch(Exception ex) { - throw new ApplicationException("Install Failed - " + ex.Message); + throw new ApplicationException("Install failed - " + ex.Message); } } diff --git a/VersionOne.ServiceHost/ServiceUtil.cs b/VersionOne.ServiceHost/ServiceUtil.cs index 7d8b057..098c15b 100644 --- a/VersionOne.ServiceHost/ServiceUtil.cs +++ b/VersionOne.ServiceHost/ServiceUtil.cs @@ -1,4 +1,3 @@ -/*(c) Copyright 2012, VersionOne, Inc. All rights reserved. (c)*/ using System; using System.Runtime.InteropServices; using System.ServiceProcess; @@ -71,11 +70,12 @@ private static extern IntPtr CreateService(IntPtr scHandle, string lpSvcName, st public static bool InstallService(string svcPath, string svcName, string svcDispName, string svcUsername, string svcPassword) { var scm = OpenSCManager(null, null, ScManagerCreateService); - if (scm.ToInt32() != 0) { + // 09-08-2015 Fixed D-09804. Changed from scm.ToInt32() to scm.ToInt64(). + if (scm.ToInt64() != 0) { var svc = CreateService(scm, svcName, svcDispName, ServiceAllAccess, ServiceWin32OwnProcess, ServiceAutoStart, ServiceErrorNormal, svcPath, null, 0, null, svcUsername, svcPassword); - var installed = svc.ToInt32() != 0; + var installed = svc.ToInt64() != 0; CloseServiceHandle(scm); return installed; } @@ -98,10 +98,11 @@ public static void StopService(string svcName) { public static bool UnInstallService(string svcName) { var scHandle = OpenSCManager(null, null, GenericWrite); - if(scHandle.ToInt32() != 0) { + // 09-08-2015 Fixed D-09804. Changed from scm.ToInt32() to scm.ToInt64(). + if(scHandle.ToInt64() != 0) { var svcHandle = OpenService(scHandle, svcName, Delete); - if (svcHandle.ToInt32() != 0) { + if (svcHandle.ToInt64() != 0) { var i = DeleteService(svcHandle); CloseServiceHandle(scHandle); return i != 0;