[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Reading stdout from the Windows script host object

Posted on 2003-12-04
3
Medium Priority
?
586 Views
Last Modified: 2010-05-01
Nothing is returning from the .read call ??
Any ideas on why this isn't working and what I should do to enable it??

Private Sub Command1_Click()

    Dim objwsh As New WshShell
    Dim sInput As String

    Set objWSHexec = objwsh.Exec("ipconfig")

    While Not objWSHexec.StdOut.AtEndOfStream
          sInput = sInput & objWSHexec.StdOut.Read(1)
         If InStr(sInput, "Press any key") <> 0 Then
            Exit Sub
         End If
    Wend
   
End Sub
0
Comment
Question by:mccainz2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 800 total points
ID: 9876382
Try this

Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("%comspec% /c ipconfig.exe")

Do Until objExecObject.StdOut.AtEndOfStream
    strLine = objExecObject.StdOut.ReadLine()
    strIP = Instr(strLine,"Address")
    If strIP <> 0 Then
        Wscript.Echo strLine
    End If
Loop


From http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/scrguide/sas_wsh_pkoy.asp
0
 
LVL 5

Author Comment

by:mccainz2
ID: 9876500
Excellent Eddy! what is the purpose of comspec ????

Final code , only trivial modifications needed....

Private Sub Command2_Click()

    Dim Wscript As New WshShell
   
    Set objShell = New WshShell
    Set objExecObject = objShell.Exec("%comspec% /c ipconfig.exe")

    Do Until objExecObject.StdOut.AtEndOfStream
        strline = objExecObject.StdOut.ReadLine()
        Debug.Print strline
        strIP = InStr(strline, "Address")
    Loop

End Sub
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9876665
In WindowNT or high %comspec% returns cmd.exe
In Win95 or higher %comspec% returns command.exe
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question