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
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
本文介绍了一段使用VBA代码来自动配置Windows系统的网络参数的方法,包括设置静态IP地址、子网掩码、默认网关及DNS服务器。
589

被折叠的 条评论
为什么被折叠?



