1

有人可以帮我把这个 .cmd 翻译成 c#

@echo off

title Windows Activation check by dsoft

cscript C:\Windows\system32\slmgr.vbs /dli | FIND "259200" >NUL
IF '%ERRORLEVEL%' EQU '0' (
echo Windows is already activated.
) ELSE (
echo Windows is not activated, Try later again.
)
pause
4

1 回答 1

2

您需要为 cscript 启动一个进程并提供 vbs 文件和 Find 命令作为参数。可以通过退出代码检查结果:

        Process p = new Process();
        p.StartInfo.FileName = "cscript";
        p.StartInfo.Arguments = " C:\\Windows\\system32\\slmgr.vbs /dli | FIND \"259200\" >NUL";
        p.Start();
        p.WaitForExit();

        if (p.ExitCode == 0)
        {
            MessageBox.Show("Windows is already acivated.");
        }
        else
        {
            MessageBox.Show("Windows is not activated, Try later again.");
        }
于 2013-08-15T13:43:21.687 回答