以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  XP系统跑CMD  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=154584)

--  作者:455631117
--  发布时间:2020/9/19 11:02:00
--  XP系统跑CMD
你好,我要获取XP系统的生产日期,调用CMD,但是在XP系统上运行会卡死,代码如下
Dim p As new Process()
Dim strrst As String
Dim scrq As String 
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False \'关闭Shell的使用
p.StartInfo.RedirectStandardInput =  True \'重定向标准输入
p.StartInfo.RedirectStandardOutput = True \'重定向标准输出
p.StartInfo.RedirectStandardError =  True \'重定向错误输出
p.StartInfo.CreateNoWindow = True \'设置不显示窗口
p.Start()
p.StandardInput.WriteLine("wmic bios get releasedate")
p.StandardInput.WriteLine("exit")
strrst = p.StandardOutput.ReadToEnd()
strrst = strrst.replace(" ","").replace(vbcr,"").Replace(vblf,"") \'去掉了空格,换行和回车
Dim ml As String = "releasedate"
strrst = strrst.Remove(0,strrst.LastIndexOf(ml))   \'删除从第一个到ml最后一次出现的位置
strrst = strrst.Remove(0,ml.Length * 2)
scrq = strrst.SubString(0,4) & "年" & strrst.SubString(4,2) & "月" & strrst.SubString(6,2) & "日"   \'得到生产日期



还有获取电脑MAC地址的:wmic nic where netconnectionid!=NULL get macaddress
在XP系统上直接在CMD中可以运行,用狐表调用就不行,是什么问题


--  作者:有点蓝
--  发布时间:2020/9/19 11:16:00
--  
XP系统不支持这种用法

获取mac可以试试:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=59092

--  作者:455631117
--  发布时间:2020/9/21 8:55:00
--  
老师,我这种获取电脑生产日期的方法不能在XP系统上运行吗?请问有没有别的方法可以在XP上运行获取生产日期的
--  作者:有点蓝
--  发布时间:2020/9/21 9:12:00
--  
不能在XP系统上运行。其它方法百度了一下没找到
--  作者:455631117
--  发布时间:2020/9/24 16:05:00
--  

你好老师,我后来又看了一下,这个CMD命令可以在XP上运行,但是狐表不能获取返回值,后来我用了这个方法:

 

shell("cmd.exe /c wmic bios get releasedate >> d:\\scrq.txt")
shell("cmd.exe /c wmic nic where netconnectionid!=NULL get macaddress >> d:\\MAC.txt")

 

 

把CMD命令执行后的内容保存为txt文件,然后读取TXT文件的内容,问题就解决了,希望可以帮到更多的朋友