Skip to content

Commit

Permalink
fix #7
Browse files Browse the repository at this point in the history
  • Loading branch information
jm33-m0 committed Oct 23, 2021
1 parent 2b51b8d commit 102bc8f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
59 changes: 49 additions & 10 deletions win10-activate/ActOffice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ public static void OfficeActivate()
// ospp root
string root = "";

// make vol
Process makeVol = new Process();
// procinfo
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "cscript.exe",
WorkingDirectory = @"C:\",
Arguments = @"//Nologo ospp.vbs /sethst:kms.jm33.me",

CreateNoWindow = true,
UseShellExecute = false,
Expand All @@ -35,21 +33,18 @@ public static void OfficeActivate()
// change KMS server
mainW.Dispatcher.Invoke(() =>
{
// convert to VOL if needed
root = mainW.OsppPath.Text;
startInfo.WorkingDirectory = mainW.OsppPath.Text;
startInfo.Arguments = "//Nologo ospp.vbs /sethst:" + mainW.TextBox.Text;
});
if (Util.YesNo("Convert to VOL? This might fail!", "Retail to VOL convertor"))
{
Retail2Vol(root);
}

if (IsOfficeActivated(root))
{
return;
}

Retail2Vol(root);

Process kmsServer = new Process
{
StartInfo = startInfo
Expand Down Expand Up @@ -113,11 +108,21 @@ public static bool IsOfficeActivated(string root)
activate.Start();
string activateDbg = activate.StandardOutput.ReadToEnd();
activate.WaitForExit();

// Check Office activation
mainW.Dispatcher.Invoke(() =>
{
if (mainW.ShowDebug.IsChecked == true)
{
MessageBox.Show("Checking if Office is activated:\n" + activateDbg,
"Debug",
MessageBoxButton.OK,
MessageBoxImage.Asterisk);
}

if (activateDbg.Contains("activation successful") ||
activateDbg.Contains("0xC004F009"))
activateDbg.Contains("0xC004F009") ||
activateDbg.Contains("LICENSE STATUS: ---LICENSED---"))
{
mainW.button.Content = "Done! Click to exit";
mainW.button.IsEnabled = true;
Expand All @@ -144,12 +149,45 @@ public static void Retail2Vol(string installRoot)
* product key is of Office Pro Plus
*/
{
string dstatus = Util.RunProcess("cscript.exe", "//NoLogo ospp.vbs /dstatus", installRoot, false);
string dstatus;
try
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "cscript.exe",
WorkingDirectory = installRoot,
Arguments = @"//Nologo ospp.vbs /dstatus",

CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
WindowStyle = ProcessWindowStyle.Hidden
};

// check license status
Process checkLicense = new Process
{
StartInfo = startInfo
};
checkLicense.Start();
dstatus = checkLicense.StandardOutput.ReadToEnd();
checkLicense.WaitForExit();
}
catch (Exception err)
{
MessageBox.Show("Retail2Vol\n" + err.ToString(), "Exception caught", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}

if (dstatus.ToLower().Contains("volume"))
{
return;
}

if (!Util.YesNo("You are not using a VOL version, try converting?", "Retail2Vol"))
{
return;
}
string licenseDir = installRoot + @"..\root\License";
string key, visioKey, version;

Expand Down Expand Up @@ -186,6 +224,7 @@ public static void Retail2Vol(string installRoot)
}
else
{
MessageBox.Show("No compatible Office version found, exit?", "Goodbye", MessageBoxButton.OK, MessageBoxImage.Stop);
return;
}

Expand Down
9 changes: 0 additions & 9 deletions win10-activate/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ private void Button_Click(object sender, RoutedEventArgs e)
Application.Current.Shutdown();
}

if (office_option.IsChecked.Value)
// Office has to be vol
{
if (!Util.YesNo("If you are not using a VOL version, kms-activate will try to convert it", "Proceed?"))
{
return;
}
}

// Disable all buttons
button.Content = "Please wait...";
button.IsEnabled = false;
Expand Down
3 changes: 2 additions & 1 deletion win10-activate/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ public static string RunProcess(string name, string args, string workdir, bool s
}
catch (Exception err)
{
MessageBox.Show(err.ToString(), "Exception caught", MessageBoxButton.OK, MessageBoxImage.Error);
MessageBox.Show("RunProcess\n" + err.ToString(), "Exception caught", MessageBoxButton.OK, MessageBoxImage.Error);
return "";
}

string output = proc.StandardOutput.ReadToEnd().ToLower();
proc.WaitForExit();
return output;
}

Expand Down

0 comments on commit 102bc8f

Please sign in to comment.