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?
1 7524
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, -
Private Type QOCINFO
-
dwSize As Long
-
dwFlags As Long
-
dwInSpeed As Long 'in bytes/second
-
dwOutSpeed As Long 'in bytes/second
-
End Type
-
-
Private Declare Function IsDestinationReachable Lib "SENSAPI.DLL" Alias "IsDestinationReachableA" (ByVal lpszDestination As String, ByRef lpQOCInfo As QOCINFO) As Long
-
-
Private Sub Form_Load()
-
Dim Ret As QOCINFO
-
Dim IP As String
-
Ret.dwSize = Len(Ret)
-
'Put desired IP here
-
IP = "127.0.0.1"
-
-
If IsDestinationReachable(IP, Ret) = 0 Then
-
MsgBox "The destination cannot be reached!"
-
Else
-
MsgBox "The destination can be reached!" + vbCrLf + _
-
"The speed of data coming in from the destination is " + Format$(Ret.dwInSpeed / 1048576, "#.0") + " Mb/s," + vbCrLf + _
-
"and the speed of data sent to the destination is " + Format$(Ret.dwOutSpeed / 1048576, "#.0") + " Mb/s."
-
End If
-
End Sub
-
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?
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
| |