private async Task InitNetAccess() { Pass = new MyPassword(); while (!Pass.GetLoginInfoFromRegistry()) { var result = await Task.Run(() => MessageBox.Show("ユーザー情報を入力してください。", "Password not found", MessageBoxButton.OKCancel)); if (result == MessageBoxResult.Cancel) { // Quit the program Application.Current.Shutdown(); return; } await RunProcessNoWindow("powershell.exe", @"-ExecutionPolicy Bypass -File .\SavePassword.ps1"); } Net = new NetAccess(); while (!IsLoggedIn) { Net.SupplyLoginInfo(Pass.CompanyCode, Pass.UserId, Pass.Password); if ((IsLoggedIn = await Net.Login()) == true) { break; } var result = await Task.Run(() => MessageBox.Show("ユーザー情報が間違っているようです。入れ直しますか?", "Unable to login", MessageBoxButton.OKCancel)); if (result == MessageBoxResult.Cancel) { // Quit the program Application.Current.Shutdown(); return; } await RunProcessNoWindow("powershell.exe", @"-ExecutionPolicy Bypass -File .\ClearPassword.ps1"); await RunProcessNoWindow("powershell.exe", @"-ExecutionPolicy Bypass -File .\SavePassword.ps1"); Pass.GetLoginInfoFromRegistry(); } }