private void BackupKey_Click(object sender, EventArgs e) { string productKey = LicensingHelper.GetProductKey(); if (productKey == null) { MessageBox.Show( "No Product key is currently installed. No backup is necessary.", "No Product key installed" ); return; } SaveFileDialog dialog = new SaveFileDialog(); dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); dialog.RestoreDirectory = true; dialog.Title = "Backup current Product key"; dialog.FileName = "product-key.txt"; dialog.CheckPathExists = true; dialog.OverwritePrompt = true; dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { File.WriteAllText( dialog.FileName, "Product key backup file created by jaw - " + DateTime.Now.ToString(CultureInfo.CurrentCulture) + Environment.NewLine + productKey + Environment.NewLine, Encoding.UTF8 ); } }
// gets Windows edition and current product key, updates GUI with available actions private async Task <bool> Step1Update() { // windows edition string s = await Task.Run( () => { return(LicensingHelper.GetWindowsSKU()); }); // current product key string oldkey = await Task.Run( () => { return(LicensingHelper.GetProductKey()); }); step1output.Text = s; // update gui if (s != null) { string key = SkuToProductKey.Get(s); if ((key != null && !key.Equals(oldkey)) || key == null) { step1action.Text = "Action: backup current key and install VL key."; previousStepEnabled |= step1.Enabled = true; } else { step1action.Text = "No action necessary: VL key is installed."; step1.Enabled = false; } } return(true); }
private async void DeleteProductKey_Click(object sender, EventArgs e) { Enabled = false; LicensingHelper.ClearProductKeys(); await UpdateGui(); Enabled = true; }
private async void InstallSrv_Click(object sender, EventArgs e) { Enabled = false; MessageBox.Show( "JAW will now start vlmcsd and configure the Software Licensing Service. This should " + "take a few seconds, but on particularly slow systems it could take a few minutes.", "Software Licensing Service" ); // service IPAddress ipa = ServiceHelper.RegisterAndStartVlmcsd(); if (ipa == null) { MessageBox.Show( "Failed to start the service.", "Service setup error", MessageBoxButtons.OK, MessageBoxIcon.Error); Enabled = true; return; } // activate if (!LicensingHelper.KmsActivate(ipa)) { MessageBox.Show( "Failed to activate Windows.", "Licensing Service error", MessageBoxButtons.OK, MessageBoxIcon.Error); Enabled = true; return; } await UpdateGui(); Enabled = true; }
private async void InstallKey_Click(object sender, EventArgs e) { Enabled = false; MessageBox.Show( "JAW will now uninstall all product keys and install the correct one. This should " + "take a few seconds, but on particularly slow systems it could take a few minutes.", "Software Licensing Service" ); string sku = LicensingHelper.GetWindowsSKU(); string key = SkuToProductKey.Get(sku); if (key == null) { using (InputBox keyInput = new InputBox()) { keyInput.ShowDialog(); if (keyInput.InputValid) { key = keyInput.Input; SkuToProductKey.SetOverrideKey(key); } else { MessageBox.Show( "The Product key you've inserted is not valid.", "Product key invalid." ); Enabled = true; return; } } } LicensingHelper.SetProductKey(key); await UpdateGui(); Enabled = true; }