Solved

Call EXE From VBScript, Trap Output, and Add Registry key

Posted on 2004-10-07
3
3,490 Views
Last Modified: 2012-05-05
I need to write a VBScript which will run an external command line EXE and trap the console output form this 3rd party tool.  Depending on the output, I need to add a registry key or not.

How would I go about this?

Thanks!
0
Comment
Question by:winterminute
  • 2
3 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 12254500
   Dim objWShell, objWExec, strOutput
    Set objWShell = CreateObject("WScript.Shell")
    Set objWExec = objWShell.Exec("ping 127.0.0.1")
    strOutput = objWExec.StdOut.ReadAll()
    Call MsgBox(strOutput)
    Set objWExec = Nothing
    Set objWShell = Nothing
0
 
LVL 2

Author Comment

by:winterminute
ID: 12254526
Okay, cool -- We're half way there -- I need to check that output to see if a string exists.
The output will be differnet each time but there will be a status line which I need to check for.
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 100 total points
ID: 12254810
You should supply an example output for both statuses and which you want to parse them for.

Nonetheless, here's an example of searching for a string within a string:

Private Sub Form_Load()
    'search "my string test" for "string".. will return true
    If StringFind("my string test", "string") = True Then
        Call MsgBox("Found string.")
    End If
    'search "my string test" for "no".. will return false
    If StringFind("my string test", "no") = True Then
        Call MsgBox("Found string.")
    End If
End Sub
Private Function StringFind(ByVal strSearchIn As String, ByVal strSearchFor As String) As Boolean
    If InStr(1, strSearchIn, strSearchFor, vbTextCompare) > 0 Then
        StringFind = True
    End If
End Function
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

766 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