Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
If InStr(Run("c:\windows\system32\rasdial","adsl username password"),"命令已完成") > 0 Then
Log("拨号成功")
Else
Log("拨号失败")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button2.Click
If InStr(Run("c:\windows\system32\rasdial","/d"),"命令已完成") > 0 Then
Log("断开成功")
Else
Log("断开失败")
End If
End Sub
Private Function Run(ByVal PROGRAM As String,ByVal TEST As String) As String
Dim pX As System.Diagnostics.Process = New System.Diagnostics.Process
pX.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
pX.StartInfo.CreateNoWindow = True
pX.StartInfo.UseShellExecute = False
pX.StartInfo.RedirectStandardOutput = True
pX.StartInfo.FileName = PROGRAM
pX.StartInfo.WorkingDirectory = "c:\"
pX.StartInfo.Arguments = TEST
pX.Start()
pX.WaitForExit()
Return pX.StandardOutput.ReadToEnd
pX = Nothing
End Function
百科参考:
rasdial命令的使用
一、rasdial命令格式:
rasdial命令三种使用方法,先列出如下,并在其后对其做相应解释。