Get a list of IP addresses of machines connected to the same network

ruimac

Member
Is there a way to get a list of IP addresses (or hostnames) of all machines that are ON AIR, connected to the same network that my machine is connected?

Edit: Forgot to say that it is for Template Wizard.
 
Last edited:
No
but if you have a list of possible hosts you can built a function to return true if you can connect to viz
 
I was trying something like:

Code:
for i = 120 to 150
    host = "192.168.109."&i
    result = QuerySingle (host,"0 VERSION \0")
    Msgbox host&" - "&result
next

But as soon as I try to send a message to an IP that does not have a Viz, the code stops after a few seconds, with the message:

EDotNetException: No connection could be made because the target machine actively refused it
 
I'm trying now with

Code:
    On Error Resume Next

    for i = 126 to 145
        host = "192.168.109."&i
        result = "Not Found"
        Err.Clear
        result = QuerySingle (host,"0 VERSION \0")
        Msgbox host&" - "&result
    next

    On Error Goto 0

And it works without errors. But, for the machines that don't have Viz or Viz is not running, it takes a long time trying to get an answer. So, simply checking 20 machines, takes a LOOOOOONG TIME. Is there any way to make this faster?
 
I'm trying now with

Code:
    On Error Resume Next

    for i = 126 to 145
        host = "192.168.109."&i
        result = "Not Found"
        Err.Clear
        result = QuerySingle (host,"0 VERSION \0")
        Msgbox host&" - "&result
    next

    On Error Goto 0

And it works without errors. But, for the machines that don't have Viz or Viz is not running, it takes a long time trying to get an answer. So, simply checking 20 machines, takes a LOOOOOONG TIME. Is there any way to make this faster?
you can try running a ps1 script that will check if viz is running, write the result to a file and then commmunicate only with the machines that viz is running on.
however, PowerShell must probably have Admin rights and you might have other security issues (you might get a call from the security boss ;))
here is a ps1 that I could only check on my local hos, save it to "C:\Temp\isVizRuning.ps1":
Code:
param (
   [string]$computerName
)

$processName = "viz" # Replace with the actual process name
$outputFile = "C:\temp\runningViz.txt"

try {
   $process = Get-Process -ComputerName $computerName -Name $processName -ErrorAction Stop
   if ($process) {
      "$processName is running on $computerName." | Out-File $outputFile
   }
   else {
      "$processName is not running on $computerName." | Out-File $outputFile
   }
}
catch {
   "$processName is not running on $computerName." | Out-File $outputFile
}
here is VTW script :
Code:
Sub TWUniButton1Click(Sender)
Dim machines
machines = Array("127.1.1.1","192.168.109.126", "192.168.109.127") ' Example IPs

Dim i, objShell, command, outputFile, fileSystem, fileContents

   Set objShell = CreateObject("WScript.Shell")
   outputFile = "C:\temp\runningViz.txt"

   For i = 0 To UBound(machines)
    ' Construct PowerShell command
      command = "powershell.exe -File C:\Temp\isVizRuning.ps1 -computerName " & machines(i)

      ' Run the PowerShell script
      objShell.Run command, 0, True
   Next
   command = "powershell.exe -File C:\Temp\isVizRuning.ps1 -computerName localhost"
   objShell.Run command, 0, True
   Timer1.Enabled = true

  Set objShell = Nothing
  Set fileSystem = Nothing

End sub

Sub Timer1Timer(Sender)
    Timer1.Enabled = false
     TWUniMemo1.lines.LoadFromFile "C:\temp\runningViz.txt"
     msgbox "loaded"
End sub
Screenshot VTW.png
Hope it works, let us all know
 
Thank you so much, @adishin

In the ps1 code, it says that...

$processName = "viz" # Replace with the actual process name

My processes are these:

processes.png

What name should I assign to the variable $processName ?
 
Back
Top