none
How to run batch command in vbscript? RRS feed

  • Question

  • Set objShell = WScript.CreateObject("WScript.Shell")
    strCmd = "%comspec% /c ""@echo off && for /F ""tokens=* skip=1"" %%n in ('WMIC path Win32_VideoController get Name ^| findstr "".""') do echo %%n"" "

    Set objExecObject = objShell.Exec(strCmd)
    strText = ""

    Do Until objExecObject.StdOut.AtEndOfStream
        strText = strText & objExecObject.StdOut.ReadLine()
    Loop

    Wscript.Echo strText

    But the output is blank. help.


    • Edited by bobsadino Wednesday, September 19, 2018 9:28 AM
    Wednesday, September 19, 2018 9:26 AM

Answers

All replies

  • It will be on a laptop.

    Use PowerShell:

    Get-WmiObject Win32_VideoController  | select name


    \_(ツ)_/

    Wednesday, September 19, 2018 9:32 AM
  • For completeness here is the VBScript version of this:

    Set wmi = GetObject("winmgmts:")
    Set colItems = wmi.ExecQuery("Select * from Win32_VideoController")
    For Each objItem in colItems
    	WScript.Echo "Name: " & objItem.Name
    Next
    


    \_(ツ)_/

    Wednesday, September 26, 2018 2:10 PM