@@ -102,6 +102,11 @@ public enum StartMode
102102 }
103103
104104 public static string GetServiceInstallArgs ( string serviceName , string userName , string password , StartMode mode = StartMode . AutomaticDelayedStart )
105+ {
106+ return GetServiceInstallArgs ( serviceName , ServicePath , userName , password , mode ) ;
107+ }
108+
109+ public static string GetServiceInstallArgs ( string serviceName , string binPath , string userName , string password , StartMode mode = StartMode . AutomaticDelayedStart )
105110 {
106111 var modeString = mode switch
107112 {
@@ -111,7 +116,7 @@ public static string GetServiceInstallArgs(string serviceName, string userName,
111116 StartMode . Disabled => "disabled" ,
112117 _ => throw new ArgumentOutOfRangeException ( nameof ( mode ) , mode , null )
113118 } ;
114- var args = $ "create { serviceName } binpath=\" { ServicePath } \" start={ modeString } ";
119+ var args = $ "create { serviceName } binpath=\" { binPath } \" start={ modeString } ";
115120 if ( ! string . IsNullOrEmpty ( userName ) )
116121 {
117122 args += $ " obj=\" { userName } \" ";
@@ -309,6 +314,12 @@ private static SCCommandResult SetServiceRecovery(string serviceName)
309314
310315 public static SCCommandResult InstallService ( string serviceName , string userName , string password ,
311316 StartMode mode = StartMode . AutomaticDelayedStart )
317+ {
318+ return InstallService ( serviceName , ServicePath , "Monitoring tool for SQL Server. https://dbadash.com" , userName , password , mode ) ;
319+ }
320+
321+ public static SCCommandResult InstallService ( string serviceName , string binPath , string description , string userName , string password ,
322+ StartMode mode = StartMode . AutomaticDelayedStart )
312323 {
313324 var result = new SCCommandResult ( ) ;
314325 var outputBuilder = new StringBuilder ( ) ;
@@ -322,8 +333,8 @@ public static SCCommandResult InstallService(string serviceName, string userName
322333 }
323334
324335 using Process p = new ( ) ;
325- var args = GetServiceInstallArgs ( serviceName , userName , password , mode ) ;
326- var DebugArgs = GetServiceInstallArgs ( serviceName , userName , string . IsNullOrEmpty ( password ) ? string . Empty : "*****" , mode ) ;
336+ var args = GetServiceInstallArgs ( serviceName , binPath , userName , password , mode ) ;
337+ var DebugArgs = GetServiceInstallArgs ( serviceName , binPath , userName , string . IsNullOrEmpty ( password ) ? string . Empty : "*****" , mode ) ;
327338 Log . Information ( $ "sc.exe { DebugArgs } ") ;
328339 var psi = new ProcessStartInfo
329340 {
@@ -350,7 +361,7 @@ public static SCCommandResult InstallService(string serviceName, string userName
350361 if ( p . ExitCode == 0 )
351362 {
352363 Log . Information ( "Setting service description" ) ;
353- var descriptionResult = SetServiceDescription ( serviceName , "Monitoring tool for SQL Server. https://dbadash.com" ) ;
364+ var descriptionResult = SetServiceDescription ( serviceName , description ) ;
354365 if ( ! descriptionResult . Success )
355366 {
356367 Log . Error ( "Error setting service description: {result}" , descriptionResult . Output ) ;
0 commit comments