- '示例:vbs读取批处理或cmd命令返回的字符串,隐藏黑框
- Set oWshShell = CreateObject("WScript.Shell")
- Set oFSO = CreateObject("Scripting.FileSystemObject")
- s = oWshShell.ExpandEnvironmentStrings("%windir%\System32\CScript.exe")
- If oFSO.FileExists(s) And LCase(WScript.FullName) <> LCase(s) Then
- s = s & " """ & WScript.ScriptFullName & """ "
- For Each i In WScript.Arguments
- If InStr(i, " ") > 0 Then i = """" & i & """"
- s = s & i & " "
- Next
- oWshShell.Run Left(s, Len(s) - 1), 0
- WScript.Quit()
- End If
-
- Set oWshScriptExec = oWshShell.Exec("cmd.exe")
- With oWshScriptExec.StdIn
- .WriteLine "@echo off & query user"
- .Close()
- End With
- With oWshScriptExec.StdOut
- s = .ReadAll()
- .Close()
- End With
- MsgBox s
-
- Set oWshScriptExec = oWshShell.Exec("cmd.exe")
- With oWshScriptExec.StdIn
- .WriteLine "@echo off & D:\test.bat"
- .Close()
- End With
- With oWshScriptExec.StdOut
- s = .ReadAll()
- .Close()
- End With
- MsgBox s
复制代码
|