RiverGuy,
I tested your above code and got it working on a test button but I am having issue with incorporating it with my code.
Test code working was:
Dim servers As Object
For Each servers In lstServers.Items
Try
My.Computer.Network.Ping(servers)
FileOpen(1, "c:\temp\test.csv", OpenMode.Append)
Print(1, servers, ",OK")
Print(1, vbCr)
FileClose(1)
Catch ex As Exception
FileOpen(1, "c:\temp\test.csv", OpenMode.Append)
Print(1, servers, ",unreachable")
Print(1, vbCr)
FileClose(1)
End Try
Next
MsgBox("COMPLETE")
Code not working: what I have noticed is that I cannot place the Next in the code that is not working outside of the End Try, this causes it to stop when it hits a server that does not respond.
Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
Dim serveritems As Object
If File.Exists(txtCSVFile.Text) Then
MsgBox("found")
Else
MsgBox("Creating CSV file")
FileOpen(1, txtCSVFile.Text, OpenMode.Output)
Print(1, "Server Name,Status,")
Dim airid As String
For Each airid In lstairid.Items
Print(1, airid & ",")
Next
Print(1, vbCr)
FileClose(1)
End If
Dim MyRegKey, MyRegKey2 As Microsoft.Win32.RegistryKey
Dim MyVal, MyVal2
lblstart.Visible = True
Dim imp As New RunAs_Impersonator
Try
imp.ImpersonateStart(cmbDomain.SelectedValue, txtUserID.Text, txtpword.Text)
Dim SERVERFILE_NAME, AIRIDFILE_NAME, CSVFILE_NAME As String
SERVERFILE_NAME = txtServerFile.Text
AIRIDFILE_NAME = txtairidfile.Text
CSVFILE_NAME = txtCSVFile.Text
Dim st As Integer
Dim tt As Integer
tt = lstServers.Items.Count * lstairid.Items.Count
'Dim serveritems As Object
For Each serveritems In lstServers.Items
st = st + 1
FileOpen(1, txtCSVFile.Text, OpenMode.Append)
'MsgBox(serveritems)
My.Computer.Network.Ping(serveritems)
Print(1, serveritems & ", OK,")
FileClose(1)
lblServerTotal.Text = st & "/" & lstServers.Items.Count
Dim MyReg As Microsoft.Win32.RegistryKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, serveritems)
MyRegKey = MyReg.OpenSubKey("Software\Microsoft\Windows NT\currentVersion")
MyVal = MyRegKey.GetValue("ProductName")
'MsgBox(MyVal)
If MyVal = "Microsoft Windows Server 2003" Then
Dim aid As Object
For Each aid In lstairid.Items
Dim Myreg2 As Microsoft.Win32.RegistryKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, serveritems)
MyRegKey2 = Myreg2.OpenSubKey("SOFTWARE\Chevron\GIL\Setup\" & aid)
If MyRegKey2 Is Nothing Then
FileOpen(1, txtCSVFile.Text, OpenMode.Append)
Print(1, "Unsuccessful,")
FileClose(1)
Else
MyVal2 = MyRegKey2.GetValue("Status")
If MyVal2 = "Installed" Then
FileOpen(1, txtCSVFile.Text, OpenMode.Append)
Print(1, "Successful,")
FileClose(1)
Else
FileOpen(1, txtCSVFile.Text, OpenMode.Append)
Print(1, "Unsuccessful,")
FileClose(1)
End If
End If
Next
FileClose(1)
End If
FileOpen(1, txtCSVFile.Text, OpenMode.Append)
Print(1, vbCr)
FileClose(1)
Next
Catch ex As Exception
Print(1, ",,unreachable")
Print(1, vbCr)
FileClose(1)
End Try
FileClose(1)
MsgBox("Complete")
lblstart.BackColor = Color.DarkSeaGreen
lblstart.Text = "Complete"
End Sub