Skip to content

cStdIO Standard Input/Output Component

Overview

cStdIO is a command-line execution component provided by the VBMAN framework, used to execute external command-line programs in VB6 and capture their standard output. Supports timeout control, working directory setting, and process exit code retrieval.

Features

  • Capture Output - Fully capture command line standard output (STDOUT)
  • Hide Window - Execute in background, no command line window shown
  • Timeout Control - Can set execution timeout to prevent process deadlock
  • Working Directory - Supports specifying working directory for command execution
  • Exit Code Retrieval - Get process exit code to determine execution result

Quick Start

Simple Command Execution

vb
Dim StdIO As New cStdIO
Dim Output As String
Dim ExitCode As Long

' Execute command and get output
Output = StdIO.ExecuteCommand("ipconfig /all", 5000, "", ExitCode)

Debug.Print "Output: " & Output
Debug.Print "Exit code: " & ExitCode

Execute and Check Exit Code

vb
Private Sub RunGitStatus()
    Dim StdIO As New cStdIO
    Dim Result As String
    Dim ExitCode As Long
    
    Result = StdIO.ExecuteCommand("git status", 10000, "D:\\MyProject", ExitCode)
    
    If ExitCode = 0 Then
        Debug.Print "Git status: " & vbCrLf & Result
    Else
        Debug.Print "Command execution failed, exit code: " & ExitCode
    End If
End Sub

Timeout Handling

vb
Private Sub RunWithTimeout()
    Dim StdIO As New cStdIO
    Dim Result As String
    Dim ExitCode As Long
    
    On Error GoTo ErrorHandler
    
    ' Set 5 second timeout
    Result = StdIO.ExecuteCommand("long-running-task.exe", 5000, "", ExitCode)
    Debug.Print Result
    Exit Sub
    
ErrorHandler:
    If InStr(Err.Description, "timeout") > 0 Then
        MsgBox "Command execution timeout!", vbExclamation
    End If
End Sub

Typical Use Cases

ScenarioExample Command
System Infoipconfig /all, systeminfo
Git Operationsgit status, git log --oneline
File Operationsdir /s, findstr "keyword" *.txt
Network Testping 8.8.8.8, tracert baidu.com
Buildmsbuild MyProject.sln

Notes

  1. Timeout - Unit is milliseconds, default 10 seconds
  2. Hide Window - Command line window auto hidden, background execution
  3. Encoding Issue - Output text encoding depends on system default encoding
  4. Large Data - Large output may occupy more memory

VB6 and LOGO copyright of Microsoft Corporation