分享

用VB.NET实现设置计算机IP地址

 趋明 2012-03-12

 
Private Sub Button_Click()
        Dim p As New Process()
        p.StartInfo.FileName = "cmd.exe"
        p.StartInfo.UseShellExecute = False
        p.StartInfo.RedirectStandardInput = True
        p.StartInfo.RedirectStandardOutput = True
        p.StartInfo.RedirectStandardError = True
        p.StartInfo.CreateNoWindow = True
        p.Start()
        p.StandardInput.WriteLine("netsh interface ip set address " + " ""本地连接"" " + " static 192.168.0.108 255.255.255.0 192.168.0.1 1")
        p.StandardInput.WriteLine("netsh -c interface ip set dns name=" + " ""本地连接"" " + " source=static addr=220.189.127.107 register=PRIMARY")
        p.StandardInput.WriteLine("exit")
        Dim strMessage As String = p.StandardOutput.ReadToEnd()
        If (strMessage.IndexOf("确定") <> -1) Then
            MessageBox.Show("填写ip成功!")
        Else
            MessageBox.Show("填写ip失败!!")
        End If
        p.Close()
    End Sub

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约