【发布时间】:2017-08-04 13:54:32
【问题描述】:
我尝试在 cmd 中运行此命令并将结果发送到我的 textbox4.text 但没有成功 命令: cscript "%windir%\system32\slmgr.vbs" /xpr | findstr /S /M /I /C:"永久"
结果需要进入我的 textbox4 : 机器被永久激活。
我写这段代码没有成功:
Dim qassam As String
qassam = Shell("whoami")
TextBox4.Text = CStr(qassam)
我也发现了这个但不起作用:
Dim oProcess As New Process()
Dim oStartInfo As New ProcessStartInfo("cmd.exe", "cscript %windir%\system32\slmgr.vbs /xpr | findstr /S /M /I /C:permanently ")
oStartInfo.UseShellExecute = False
oStartInfo.RedirectStandardOutput = True
oProcess.StartInfo = oStartInfo
oProcess.Start()
Dim sOutput As String
Using oStreamReader As System.IO.StreamReader = oProcess.StandardOutput
sOutput = oStreamReader.ReadToEnd()
End Using
TextBox4.Text = sOutput 'txtOutput being the output textbox.
我是 vb.net 的新手,我需要简单的代码,请理解
【问题讨论】:
-
你试过调试吗?您遇到了什么错误(如果有)?
-
我没有错误我有一个空白文本框
-
您需要查看调试 - 在代码上放置断点并检查每个点的输出。这样你就可以找出到底是什么不工作(是流还是过程?)。
标签: vb.net shell cmd textbox command