private async void Application_Startup(object sender, StartupEventArgs e) { InstallProtocol(); var args = Environment.GetCommandLineArgs(); if (args.Length > 1) { Uri argUri; string command = ""; string pass = ""; string key = ""; if (Uri.TryCreate(args[1], UriKind.Absolute, out argUri)) { var decoder = new WwwFormUrlDecoder(argUri.Query); if (decoder.Any()) { foreach (var entry in decoder) { if (entry.Name == "comm") { command = entry.Value; } else if (entry.Name == "auth") { pass = entry.Value; } else if (entry.Name == "key") { key = entry.Value; } } } switch (command) { case "shutdown": if (await PasscodeHelper.Auth(pass, key)) { ShutdownHelper.ShutdownSystem(); } else { MessageBox.Show("Authentication failed", "Error"); } break; case "reboot": if (await PasscodeHelper.Auth(pass, key)) { ShutdownHelper.RebootSystem(); } else { MessageBox.Show("Authentication failed", "Error"); } break; } App.Current.Shutdown(); } } }
private async void CodeTbk_Loaded(object sender, RoutedEventArgs e) { CodeTbk.Text = await PasscodeHelper.GetPassword(); }