VBS将Cmd命令结果赋值给变量。
function Runcmd(cmd) Dim strText Set oShell = CreateObject("WScript.Shell") Set oExec = oShell.exec("%COMSPEC% /C "&cmd) Do While Not oExec.StdOut.AtEndOfStream strText = oExec.StdOut.ReadAll() Loop Runcmd = strtextend function
用法很简单,例如
a=runcmd("ipconfig")
那么ipconfig的命令结果会保存在变量a中。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。