Private Sub ChangeProxy(ByVal IP As String, ByVal Proxy As Boolean, ByVal strAddress As String, ByVal ByPass As Boolean)
Dim strComputer
Dim strUserName
Dim strPassword
Dim objLocator
Dim objService
Dim objRegistry
Dim strKeyPath, strValueName, strValue As String
Dim dwValue As Integer
Const HKEY_CURRENT_USER = &H80000001
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings"
strComputer = IP
strUserName = UserName
strPassword = Password
Try
objLocator = CreateObject("WbemScripting.SWbemLocator")
If (IP = System.Environment.MachineName) Then
objService = objLocator.ConnectServer(strComputer, "Root\Default")
Else
objService = objLocator.ConnectServer(strComputer, "Root\Default", strUserName, strPassword)
End If
objService.Security_.impersonationlevel = 3
objRegistry = objService.Get("StdRegProv")
strValueName = "ProxyEnable"
If (Proxy) Then
dwValue = 1
objRegistry.SetDWORDValue(HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue)
strValueName = "ProxyServer"
strValue = strAddress
objRegistry.SetStringValue(HKEY_CURRENT_USER, strKeyPath, strValueName, strValue)
If (ByPass) Then
strValueName = "ProxyOverride"
strValue = txtByPass.Text
objRegistry.SetStringValue(HKEY_CURRENT_USER, strKeyPath, strValueName, strValue)
'Else
' strValueName = "ProxyOverride"
' strValue = "127.0.0.1"
' objRegistry.SetStringValue(HKEY_CURRENT_USER, strKeyPath, strValueName, strValue)
End If
Else
dwValue = 0
objRegistry.SetDWORDValue(HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue)
End If
CreateLog("Proxy Setting for IE", IP, "Proxy Address " & strValue & " Executed.", "Success")
Catch ex As Exception
CreateLog("Proxy Setting for IE", IP, "Proxy Address " & strValue & " Executed.", "Failed")
End Try
End Sub
"Ping" is very basic utility for every network programmer. Here we will discuss ping a computer in Network using VB.Net. We have two methods for pinging a computer. Method 1: Here we will use VB.Net NetworkInformation NameSpace. Public Sub PingStatus(ByVal strComputer As String) Dim pingSender As Ping = New Ping() Dim options As PingOptions = New PingOptions() options.DontFragment = True 'Create a buffer of 32 bytes of data to be transmitted Dim data As String = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" Dim buffer As Byte() = Encoding.ASCII.GetBytes(data) Dim timeout As Integer = 120 Dim reply As PingReply = pingSender.Send(strComputer, timeout, buffer, options) If (reply.Status = IPStatus.Success) Then MessageBox.Show("Ping Successed.") Else MessageBox.Show("Ping Faild.") End If End Sub Method 2: Here we are using .Net inbuil...