execute shell command

Private Function ExecuteCommand(ByVal as_command As String, ByVal as_arguments As String, Optional ByVal ai_wait As Integer = 1000) As Integer
    Dim s As System.Diagnostics.Process = New System.Diagnostics.Process

    s.StartInfo.FileName = as_command
    s.StartInfo.Arguments = as_arguments
    s.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
    s.StartInfo.CreateNoWindow = True
    s.StartInfo.UseShellExecute = False

    If s.WaitForExit(ai_wait) Then
        ExecuteCommand = s.ExitCode
        ExecuteCommand = -1
    End If
End Function

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s