@@ -205,7 +205,7 @@ public MainPage()
205205 if ( Properties . Settings . Default . showPingButton )
206206 bt_Ping . Visibility = System . Windows . Visibility . Visible ;
207207
208-
208+ bool bNoConnect = true ;
209209 try
210210 {
211211 if ( System . Deployment . Application . ApplicationDeployment . IsNetworkDeployed )
@@ -250,12 +250,16 @@ public MainPage()
250250 {
251251 if ( Environment . GetCommandLineArgs ( ) . Count ( ) > 0 )
252252 {
253- tb_TargetComputer . Text = Environment . GetCommandLineArgs ( ) [ 1 ] . Trim ( ) ;
254- tb_TargetComputer2 . Text = Environment . GetCommandLineArgs ( ) [ 1 ] . Trim ( ) ;
255- tb_TargetComputer . Text = tb_TargetComputer . Text . Replace ( "-debug" , "127.0.0.1" ) ;
256- tb_TargetComputer2 . Text = tb_TargetComputer . Text . Replace ( "-debug" , "127.0.0.1" ) ;
257- tb_TargetComputer . Text = tb_TargetComputer . Text . Replace ( "-Embedding" , "" ) ;
258- tb_TargetComputer2 . Text = tb_TargetComputer2 . Text . Replace ( "-Embedding" , "" ) ;
253+ if ( ! Environment . GetCommandLineArgs ( ) [ 1 ] . StartsWith ( "/" ) )
254+ {
255+ tb_TargetComputer . Text = Environment . GetCommandLineArgs ( ) [ 1 ] . Trim ( ) ;
256+ tb_TargetComputer2 . Text = Environment . GetCommandLineArgs ( ) [ 1 ] . Trim ( ) ;
257+ tb_TargetComputer . Text = tb_TargetComputer . Text . Replace ( "-debug" , "127.0.0.1" ) ;
258+ tb_TargetComputer2 . Text = tb_TargetComputer . Text . Replace ( "-debug" , "127.0.0.1" ) ;
259+ tb_TargetComputer . Text = tb_TargetComputer . Text . Replace ( "-Embedding" , "" ) ;
260+ tb_TargetComputer2 . Text = tb_TargetComputer2 . Text . Replace ( "-Embedding" , "" ) ;
261+ bNoConnect = false ;
262+ }
259263 }
260264 }
261265 }
@@ -271,7 +275,7 @@ public MainPage()
271275 if ( Environment . GetCommandLineArgs ( ) . Count ( ) > 1 )
272276 {
273277 var Args = Environment . GetCommandLineArgs ( ) . ToList ( ) ;
274- bool bNoConnect = false ;
278+
275279 if ( Args . Contains ( "/RegisterConsole" , StringComparer . OrdinalIgnoreCase ) )
276280 {
277281 try
@@ -295,6 +299,23 @@ public MainPage()
295299 return ;
296300 }
297301
302+ string sUser = Args . FirstOrDefault ( t => t . StartsWith ( "/Username:" , StringComparison . CurrentCultureIgnoreCase ) ) ;
303+ string sPW = Args . FirstOrDefault ( t => t . StartsWith ( "/Password:" , StringComparison . CurrentCultureIgnoreCase ) ) ;
304+
305+ if ( sUser != null && sPW != null )
306+ {
307+ sUser = sUser . Substring ( 10 ) ;
308+ sPW = sPW . Substring ( 10 ) ;
309+ if ( ! string . IsNullOrEmpty ( sUser ) && ! string . IsNullOrEmpty ( sPW ) )
310+ {
311+ tb_Username . Text = sUser ;
312+ pb_Password . Password = common . Encrypt ( sPW , Application . ResourceAssembly . ManifestModule . Name ) ;
313+ sUser = "" ;
314+ sPW = "" ;
315+ }
316+ }
317+
318+
298319 if ( ! bNoConnect )
299320 {
300321 if ( ! string . IsNullOrEmpty ( tb_TargetComputer . Text ) )
@@ -498,6 +519,7 @@ private void bt_Connect_Click(object sender, RoutedEventArgs e)
498519 }
499520 string sPW = common . Decrypt ( pb_Password . Password , Application . ResourceAssembly . ManifestModule . Name ) ;
500521 oAgent = new SCCMAgent ( sTarget , tb_Username . Text , sPW , int . Parse ( tb_wsmanport . Text ) , false , cb_ssl . IsChecked ?? false ) ;
522+ sPW = "" ;
501523 }
502524
503525 oAgent . PSCode . Listeners . Add ( myTrace ) ;
0 commit comments