Skip to content

Commit

Permalink
add option to run process with pop-up window
Browse files Browse the repository at this point in the history
  • Loading branch information
jm33-m0 committed Aug 7, 2019
1 parent 338a96f commit fd9836e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions win10-activate/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public bool IsAdmin()

public bool IsActivated()
{
string status = RunProcess("cscript.exe", @"//NoLogo slmgr.vbs /dli");
string status = RunProcess("cscript.exe", @"//NoLogo slmgr.vbs /dli", true);

if (status.Contains("license status: licensed") || status.Contains("已授权"))
{
Expand All @@ -46,18 +46,21 @@ public bool IsActivated()
return false;
}

public string RunProcess(string name, string args)
public string RunProcess(string name, string args, bool silent)
{
ProcessStartInfo procInfo = new ProcessStartInfo
{
FileName = name,
CreateNoWindow = true,
UseShellExecute = false,
WorkingDirectory = System.Environment.GetEnvironmentVariable("SystemRoot") + @"\System32",
Arguments = args,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true
};
if (silent)
{
procInfo.UseShellExecute = false;
procInfo.CreateNoWindow = true;
procInfo.WindowStyle = ProcessWindowStyle.Hidden;
procInfo.RedirectStandardOutput = true;
}

Process proc = new Process
{
Expand Down Expand Up @@ -156,7 +159,7 @@ public void WinActivate()
{
string edition = winversion.Split(' ')[winversion.Split(' ').Length - 1];
string args = "/online /set-edition:Server" + edition + " /productkey:" + key + " /accepteula";
string eval2license = RunProcess("dism.exe", args);
string eval2license = RunProcess("dism.exe", args, false);
if (eval2license == "")
{
MessageBox.Show("Evaluation version failed to be converted", "Sorry", MessageBoxButton.OK, MessageBoxImage.Stop);
Expand Down

0 comments on commit fd9836e

Please sign in to comment.