@@ -22,10 +22,10 @@ public PsdzRpcServerStarter(TextWriter output = null)
2222 _output = output ;
2323 }
2424
25- public async Task < bool > ConnectClient ( string serverExe , ProcessWindowStyle windowStyle , PsdzRpcClient client , CancellationTokenSource cts ,
25+ public async Task < bool > ConnectClient ( string serverExe , string serviceName , ProcessWindowStyle windowStyle , PsdzRpcClient client , CancellationTokenSource cts ,
2626 string userName = null , string password = null )
2727 {
28- if ( ! StartServerIfNeeded ( serverExe , windowStyle , userName , password ) )
28+ if ( ! StartServerIfNeeded ( serverExe , serviceName , windowStyle , userName , password ) )
2929 {
3030 _output ? . WriteLine ( "No server available. Exiting." ) ;
3131 return false ;
@@ -44,7 +44,7 @@ public async Task<bool> ConnectClient(string serverExe, ProcessWindowStyle windo
4444 }
4545
4646 _output ? . WriteLine ( "Try to restart server..." ) ;
47- if ( ! StartServerIfNeeded ( serverExe , windowStyle , userName , password ) )
47+ if ( ! StartServerIfNeeded ( serverExe , serviceName , windowStyle , userName , password ) )
4848 {
4949 _output ? . WriteLine ( "No server available. Exiting." ) ;
5050 return false ;
@@ -72,7 +72,7 @@ public bool IsPipeAvailable()
7272 /// Startet den Server-Prozess, falls ein Pfad angegeben ist.
7373 /// Wartet nur bis der Prozess gestartet ist, nicht bis die Pipe verfügbar ist.
7474 /// </summary>
75- public bool StartServerIfNeeded ( string serverExe , ProcessWindowStyle windowStyle , string userName , string password )
75+ public bool StartServerIfNeeded ( string serverExe , string serviceName , ProcessWindowStyle windowStyle , string userName , string password )
7676 {
7777 if ( IsPipeAvailable ( ) )
7878 {
@@ -81,7 +81,7 @@ public bool StartServerIfNeeded(string serverExe, ProcessWindowStyle windowStyle
8181 }
8282
8383 // Zuerst versuchen den Windows-Dienst zu starten
84- if ( TryStartWindowsService ( "PsdzRpcServer" ) )
84+ if ( TryStartWindowsService ( serviceName ) )
8585 {
8686 return true ;
8787 }
@@ -94,6 +94,11 @@ private bool TryStartWindowsService(string serviceName)
9494 {
9595 try
9696 {
97+ if ( String . IsNullOrEmpty ( serviceName ) )
98+ {
99+ return false ;
100+ }
101+
97102 using ServiceController sc = new ServiceController ( serviceName ) ;
98103 ServiceControllerStatus status = sc . Status ;
99104
0 commit comments