Results 1 to 4 of 4

Thread: Timer to skip/connect to next computer in for each loop while connecting remotely

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2015
    Posts
    3

    Question Timer to skip/connect to next computer in for each loop while connecting remotely

    I built a tool (with Visual Studio 2015 Express - Visual Basic) that will check the mcafee dat version and date from the registry on computers input either manually, in a text file, or selected from active directory. The tool works it successfully returned all the information for 714 out of 970 computers/laptops. The majority of the failures were either because they could not be resolved in DNS or weren't pingable and the tools identifies those and successfully logs them. It took a little over 15 minutes for the tool to retrieve the information and log it in a spreadsheet. The issue is that on 19 of the failures I got one of the two following errors and those 19 took the majority of the 15 minutes for the tool get and log all the information:


    1. Attempted to perform an unauthorized operation
    2. The network path was not found
      Is there a way of using a timer so that the program will attempt to connect to the registry at this point... rk1 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, strComputer, RegistryView.Registry64) and then after a certain amount of time stop and move to the next computer in the for each loop? I have only been programming for a little over a year and I have learned exclusively through trial/error and google so please have patience with me as I am not a seasoned programmer.

    The program works well my objective here is to improve it by making it skip to the next computer when it hangs for an extended period of time. I think it will cut the time in half. I have filtered out the computers that can't be resolved in DNS or aren't pingable. Here is the code:


    For Each sel In picker.SelectedObjects
    Try
    If HostIsResolvable(sel.Name) Then
    Try
    reply = ping.Send(sel.Name, 1)
    If reply.Status = IPStatus.Success Then
    IPAddr = reply.Address.ToString()
    Try
    comsys(sel.Name)
    Dim rk1 As RegistryKey
    Dim rk2 As RegistryKey
    rk1 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine,
    sel.Name, RegistryView.Registry64)
    rk2 = rk1.OpenSubKey("SOFTWARE\Wow6432Node\McAfee\AVEngine")
    mAV = rk2.GetValue("AVDatVersion").ToString
    mAD = rk2.GetValue("AVDatDate").ToString
    objExcel.Cells(y, 1) = sel.Name
    objExcel.Cells(y, 2) = IPAddr
    objExcel.Cells(y, 3) = commodel
    objExcel.Cells(y, 4) = comuser
    objExcel.Cells(y, 5) = "DAT Version Number: " & mAV
    objExcel.Cells(y, 6) = "DAT Date: " & mAD
    y = y + 1
    Catch ex As Exception
    Messagebox.show(ex.message)
    End Try
    Else
    Messagebox.show(sel.Name & " is not pingable!")
    End If


    Catch ex As Exception
    Messagebox.show(ex.message)
    End Try
    Else
    Messagebox.show(sel.Name & " could not be resolved in DNS!")
    End If
    Catch ex As Exception
    Messagebox.show(ex.message)
    End Try
    sel = Nothing
    Next

















  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Timer to skip/connect to next computer in for each loop while connecting remotely

    Thread moved from the CodeBank, which is for posting finished code rather than posting questions.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2015
    Posts
    3

    Re: Timer to skip/connect to next computer in for each loop while connecting remotely

    This wasn't finished code. I was asking for help with changing a part of the for each.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Timer to skip/connect to next computer in for each loop while connecting remotely

    Exactly. The CodeBank is for finished examples. Questions belong in this forum.
    My usual boring signature: Nothing

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width