473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Find Computer over network

Iv developed a small program that looks for a file over our network, and copy it to the location of another computer. Im using the "If FileExists("\\oldpc\main share\Folder\file.txt") Then" way of finding if the file exists, but i want to make it so that it tries to look for the computer, not the file. At the moment this is how i am finding and copying the file:

If FileExists("\\oldpc\main share\Folder\file.txt") Then
FileCopy "\\oldpc\main share\Folder\file.txt", "C:\Documents and Settings\All Users\Desktop\back ups\file.txt"
else
msgbox "Error"
end if

Public Function FileExists(Fname As String) As Boolean

If Fname = "" Or Right(Fname, 1) = "\" Then
FileExists = False: Exit Function
End If

FileExists = (Dir(Fname) <> "")

End Function

Instead of finding the file, i want it to find the PC, because, although the PC is connected, the file might not be at the location specified so it errors, and i want TWO different error messages. 1 saying the file is not at location, and 1 saying the computer is unable to be located. Can anyone help?
Sep 14 '06 #1
1 7524
sashi
1,754 Expert 1GB
Hi there,

There are few ways to find a computer over the network, Windows Management Instrumentation (WMI) is very useful, instead lets focus on a simpler method, ping command is will solve your prob i guess, kindly refer to below code segment,

Expand|Select|Wrap|Line Numbers
  1. Private Type QOCINFO
  2.   dwSize As Long
  3.   dwFlags As Long
  4.   dwInSpeed As Long 'in bytes/second
  5.   dwOutSpeed As Long 'in bytes/second
  6. End Type
  7.  
  8. Private Declare Function IsDestinationReachable Lib "SENSAPI.DLL" Alias "IsDestinationReachableA" (ByVal lpszDestination As String, ByRef lpQOCInfo As QOCINFO) As Long
  9.  
  10. Private Sub Form_Load()
  11.   Dim Ret As QOCINFO
  12.   Dim IP As String
  13.   Ret.dwSize = Len(Ret)
  14.   'Put desired IP here
  15.   IP = "127.0.0.1"
  16.  
  17.   If IsDestinationReachable(IP, Ret) = 0 Then
  18.     MsgBox "The destination cannot be reached!"
  19.   Else
  20.     MsgBox "The destination can be reached!" + vbCrLf + _
  21.     "The speed of data coming in from the destination is " +  Format$(Ret.dwInSpeed / 1048576, "#.0") + " Mb/s," + vbCrLf + _
  22.     "and the speed of data sent to the destination is " + Format$(Ret.dwOutSpeed / 1048576, "#.0") + " Mb/s."
  23.   End If
  24. End Sub 
  25.  
Iv developed a small program that looks for a file over our network, and copy it to the location of another computer. Im using the "If FileExists("\\oldpc\main share\Folder\file.txt") Then" way of finding if the file exists, but i want to make it so that it tries to look for the computer, not the file. At the moment this is how i am finding and copying the file:

If FileExists("\\oldpc\main share\Folder\file.txt") Then
FileCopy "\\oldpc\main share\Folder\file.txt", "C:\Documents and Settings\All Users\Desktop\back ups\file.txt"
else
msgbox "Error"
end if

Public Function FileExists(Fname As String) As Boolean

If Fname = "" Or Right(Fname, 1) = "\" Then
FileExists = False: Exit Function
End If

FileExists = (Dir(Fname) <> "")

End Function

Instead of finding the file, i want it to find the PC, because, although the PC is connected, the file might not be at the location specified so it errors, and i want TWO different error messages. 1 saying the file is not at location, and 1 saying the computer is unable to be located. Can anyone help?
Sep 14 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Ram Baruch | last post by:
Hi, I'm trying to use the File.Copy() function. It works well when the desenation file is local (Like: C:\dest\dest.exe). The problem is that when I'm trying to copy to a destenation that starts...
0
by: kvarga | last post by:
I have written an Windows Service application, in C#, which calls a web service periodically. This application works fine on a variety of Operating Systems including XP Pro, XP Home, Windows 2000...
18
by: Bruce Lawrence | last post by:
We use Access 97. We are in the process of migrating to 2003 along with SQL in most cases. We have a production database that contains a pretty important table and we would like to know which...
0
by: NoWhereMan | last post by:
Hello, I'm trying to get the list of shared folders of a network computer and add them to a combo box. I'm using the bellow code in VB .NET. Code ==== Private Sub EnumShares(ByVal Machine As...
2
by: Dawoodi Bohra | last post by:
VPN connected but cannot map folders on my computer. I am trying to connect to our headquarters server using VPN (windows XP). I am able to successfully connect to the server (passes...
0
by: Paul Brady | last post by:
I volunteer at a youth ministry agency and help them with their student database. They have two computers, both running Windows XP. Both have Office 2002 installed without Access, except that...
1
by: shriil | last post by:
Hi I am facing a problem with regard to opening of Access Databases, resident on pcs of my office network connected thru LAN, from my machine on the network. The folders in which these...
6
by: trytobreak | last post by:
Hi All, I am a network administrator in a fairly large software company and I would like to write myself a small utility, which would connect (one by one) to all machines on the network and get...
3
by: SyGC | last post by:
Hi People, Im trying to do a simple Loop where by an IP address is pinged (Using My.computer.network.ping) and the results, true or false, are used to invoke another line of code. Basically if...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.