Getting command line output in VBScript (without writing to files)

I use VBScript and my goal is to replace the drive letter of my choice. I need drive D, and if it is unavailable, I need to check if it is already mapped to the right place; then inform the user if this is not the case. I found this: http://technet.microsoft.com/en-us/library/ee156605.aspx , and I'm trying to adapt their second example:

Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("cmd /c ping -n 3 -w 1000 157.59.0.1")
Do While Not objExecObject.StdOut.AtEndOfStream
    strText = objExecObject.StdOut.ReadLine()
    If Instr(strText, "Reply") > 0 Then
        Wscript.Echo "Reply received."
        Exit Do
    End If
Loop

(my adaptations):

Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("cmd /c substr")
strText = ""

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

Wscript.Echo strText

Then I will probably look for a line that tells where the D-disk is displayed. I also tried objShell.Exec("subst"), but I still don't get any output. Anyone have any ideas on what I can do wrong? Or is there a better way to talk about drive mappings? Thank,

213897

+5
1

script , - it subst, substr.

+4

All Articles