实例介绍
【实例简介】
Win10系统,Office激活软件,获取本机信息,查看本机的激活状态等等
【实例截图】
static string ActivationName = ""; //产品名称
static string ActivationState = ""; //产品激活状态
static string ActiveVersions = ""; //激活版本
/// <summary>
/// 激活
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnActivation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
try
{
Program.FrmPromptForm_lblTips_Text = "激活产品中,请稍等......";
var Intselect = gridView.GetSelectedRows();
if (Intselect.Length == 0) { MessageBox.Show("请选择需要激活的产品..."); return; }
foreach (var selInt in Intselect)
{
ActivationName = gridView.GetDataRow(selInt).ItemArray[0].ToString();
ActivationState = gridView.GetDataRow(selInt).ItemArray[1].ToString();
ActiveVersions = gridView.GetDataRow(selInt).ItemArray[3].ToString();
if (ActiveVersions == "")
{
MessageBox.Show(ActivationName "产品未选择激活版本,请选择所需版本后激活...");
return;
}
if (ActivationState == "已激活")
{
MessageBox.Show(ActivationName "该产品已激活过,无法再次激活......");
return;
}
}
Task SystemTask; //操作系统线程
Task OfficeTask; //Office线程
Task VisioTask; //Visio线程
Task ProjectTask; //Project线程
List<Task> TasksArray = new List<Task>(); //等待线程
foreach (var selInt in Intselect)
{
ActivationName = gridView.GetDataRow(selInt).ItemArray[0].ToString();
ActivationState = gridView.GetDataRow(selInt).ItemArray[1].ToString();
ActiveVersions = gridView.GetDataRow(selInt).ItemArray[3].ToString();
switch (ActivationName)
{
case "操作系统":
{
if (ActiveVersions == "Windows 10 企业版")
{
SystemTask = Task.Run(() =>
{
CmdHelper.Command_ExecuteOutCmd($@"
slmgr -ipk W77WN-TP36G-VBJFX-C77HK-2YT44
slmgr -skms kms.03k.org
slmgr -ato
slmgr -dlv
");
});
TasksArray.Add(SystemTask);
WriteJournal();
}
else if (ActiveVersions == "Windows 10 教育版")
{
SystemTask = Task.Run(() =>
{
CmdHelper.Command_ExecuteOutCmd($@"
slmgr -ipk NW6C2-QMPVW-D7KKK-3GKT6-VCFB2
slmgr -skms kms8.MSGuides.com
slmgr -ato
slmgr -dlv
");
});
TasksArray.Add(SystemTask);
WriteJournal();
}
else if (ActiveVersions == "Windows 10 专业版")
{
SystemTask = Task.Run(() =>
{
CmdHelper.Command_ExecuteOutCmd($@"
slmgr -ipk W269N-WFGWX-YVC9B-4J6C9-T83GX
slmgr -skms kms8.MSGuides.com
slmgr -ato
slmgr -dlv
");
});
TasksArray.Add(SystemTask);
WriteJournal();
}
break;
}
case "Office":
{
if (ActiveVersions == "Office 2019 ProPlus 专业版")
{
OfficeTask = Task.Run(() =>
{
CmdHelper.Command_ExecuteOutCmd($@"
if exist ""%ProgramFiles%\Microsoft Office\Office16\ospp.vbs"" cd /d ""%ProgramFiles%\Microsoft Office\Office16""
if exist ""%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs"" cd /d ""%ProgramFiles(x86)%\Microsoft Office\Office16""
for /f %%x in ('dir /b ..\root\Licenses16\ProPlus2019VL*.xrm-ms') do cscript ospp.vbs /inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\ProPlus2019VL*.xrm-ms') do cscript ospp.vbs /inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_kms*.xrm-ms') do cscript ospp.vbs /inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_mak*.xrm-ms') do cscript ospp.vbs /inslic:""..\root\Licenses16\%%x"" >nul
cscript //nologo ospp.vbs /unpkey:6MWKP >nul
cscript //nologo ospp.vbs /inpkey:NMMKJ-6RK4F-KMJVX-8D9MJ-6MWKP >nul
set i=1
:server
if %i%==1 set KMS_Sev=kms7.MSGuides.com
if %i%==2 set KMS_Sev=kms8.MSGuides.com
if %i%==3 set KMS_Sev=kms9.MSGuides.com
if %i%==4 goto notsupported
cscript //nologo ospp.vbs /sethst:%KMS_Sev% >nul
cscript //nologo ospp.vbs /act | find /i ""successful"" && (echo Complete) || (echo Trying another KMS Server & set /a i =1 & goto server)
");
});
TasksArray.Add(OfficeTask);
WriteJournal();
}
break;
}
case "Visio":
{
if (ActiveVersions == "Visio 2019 Visio 专业版")
{
VisioTask = Task.Run(() =>
{
CmdHelper.Command_ExecuteOutCmd($@"
if exist ""%ProgramFiles%\Microsoft Office\Office16\ospp.vbs"" cd /d ""%ProgramFiles%\Microsoft Office\Office16""
if exist ""%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs"" cd /d ""%ProgramFiles(x86)%\Microsoft Office\Office16""
cscript //nologo ospp.vbs /inslic:""..\root\Licenses16\pkeyconfig-office.xrm-ms"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\client-issuance*.xrm-ms') do cscript ospp.vbs /inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\visioprovl_kms*.xrm-ms') do cscript ospp.vbs /inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\visiopro2019vl_kms*.xrm-ms') do cscript ospp.vbs /inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\visio???vl_kms*.xrm-ms') do cscript ospp.vbs /inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\visio???vl_mak*.xrm-ms') do cscript ospp.vbs /inslic:""..\root\Licenses16\%%x"" >nul
cscript //nologo ospp.vbs /unpkey:7VCBB >nul
cscript //nologo ospp.vbs /inpkey:9BGNQ-K37YR-RQHF2-38RQ3-7VCBB >nul
set i=1
:server
if %i%==1 set KMS_Sev=kms8.MSGuides.com
if %i%==2 set KMS_Sev=kms9.MSGuides.com
if %i%==3 set KMS_Sev=kms7.MSGuides.com
if %i%==4 goto notsupported
cscript //nologo ospp.vbs /sethst:%KMS_Sev% >nul
cscript //nologo ospp.vbs /act | find /i ""successful"" && (echo Complete) || (echo Trying another KMS Server & set /a i =1 & goto server)
");
});
TasksArray.Add(VisioTask);
WriteJournal();
}
break;
}
case "Project":
{
if (ActiveVersions == "Visio 2019 Project 专业版")
{
ProjectTask = Task.Run(() =>
{
CmdHelper.Command_ExecuteOutCmd($@"
if exist ""%ProgramFiles%\Microsoft Office\Office16\ospp.vbs"" cd /d ""%ProgramFiles%\Microsoft Office\Office16""
if exist ""%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs"" cd /d ""%ProgramFiles(x86)%\Microsoft Office\Office16""
cscript //nologo ospp.vbs /inslic:""..\root\Licenses16\pkeyconfig-office.xrm-ms"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\client-issuance*.xrm-ms') do cscript ospp.vbs / inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\projectprovl_kms*.xrm-ms') do cscript ospp.vbs / inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\projectpro2019vl_kms*.xrm-ms') do cscript ospp.vbs / inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\project???vl_kms*.xrm-ms') do cscript ospp.vbs / inslic:""..\root\Licenses16\%%x"" >nul
for /f %%x in ('dir /b ..\root\Licenses16\project???vl_mak*.xrm-ms') do cscript ospp.vbs / inslic:""..\root\Licenses16\%%x"" >nul
cscript //nologo ospp.vbs /unpkey:PKD2B >nul
cscript //nologo ospp.vbs /inpkey:B4NPR-3FKK7-T2MBV-FRQ4W-PKD2B >nul
set i=1
:server
if %i%==1 set KMS_Sev=kms9.MSGuides.com
if %i%==2 set KMS_Sev=kms8.MSGuides.com
if %i%==3 set KMS_Sev=kms7.MSGuides.com
if %i%==4 goto notsupported
cscript //nologo ospp.vbs /sethst:%KMS_Sev% >nul
cscript //nologo ospp.vbs /act | find /i ""successful"" && (echo Complete) || (echo Trying another KMS Server & set /a i =1 & goto server)
");
});
TasksArray.Add(ProjectTask);
WriteJournal();
}
break;
}
}
}
Thread thread = new Thread(PromptForm); //提示窗体
thread.Start();
Task[] TasksResult = TasksArray.ToArray(); //数组转换
Task.WaitAll(TasksResult); //等待线程完成
CheckActivation.Check(); //重新获取激活状态
System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer() { Interval = 1000, Enabled = true };
timer.Tick = (a, b) =>
{
if (CheckActivation.OfficeSuccessful == true && CheckActivation.ProjectSuccessful == true && CheckActivation.VisioSuccessful == true && CheckActivation.SystemSuccessful == true)
{
thread.Abort();
AddGrid();
timer.Stop();
}
};
timer.Start();
}
catch
{
}
}
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论