Search code examples
c#.netwindowsc#-4.0wmi

Windows auto activate method


I need a windows activate method. My code works, but it create a popup window and I don't want it.
Is there any way to activate in background without any message?

private void tryingActivateWindows()
{
    ProcessStartInfo psi = new ProcessStartInfo("cmd", "/c " + "SLMGR -ato");
    psi.UseShellExecute = false;
    psi.CreateNoWindow = true;
    Process p = new Process();
    p.StartInfo = psi;
    p.Start();
    p.WaitForExit();
}

Solution

  • private void tryingActivateWindows()
    {
        Process activateScript = new Process();
        activateScript.StartInfo.FileName = @"cscript";
        activateScript.StartInfo.WorkingDirectory = @"C:\Windows\System32\"; 
        activateScript.StartInfo.Arguments = "//B //Nologo slmgr.vbs -ato";
        activateScript.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        activateScript.Start();
        activateScript.WaitForExit();
    }