Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

visual basic 6 determine if computer is on network

Posted on 2009-04-03
2
Medium Priority
?
221 Views
Last Modified: 2012-05-06
I want to determine if a computer is running using vb 6.0. I am implementing a fail-over system and wanted something that returns the information quickly
0
Comment
Question by:adimit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Expert Comment

by:c0ldfyr3
ID: 24066741
Here´s a very quick and dirty way to do with vbscript. You can´t do itwith VB as the application will fail to load if the redistributablesaren´t installed!

Option Explicit
 
Const SYSTEM32 = &H25&
 
Dim objShell, objFolder, objFolderItem, objFSO, sPath, sFile
 
Set objShell = CreateObject("Shell.Application")
Set objFSO =  CreateObject("Scripting.FileSystemObject")
Set objFolder = objShell.Namespace(SYSTEM32)
Set objFolderItem = objFolder.Self
 
sPath = objFolderItem.Path
 
If Right(sPath,1) <> "\" Then sPath = sPath & "\"
 
sFile = sPath & "Msvbvm60.dll"
If objFSO.FileExists( sFile ) Then
    Wscript.Echo "VB6 Installed"
End If
 
sFile = sPath & "Msvbvm50.dll"
If objFSO.FileExists( sFile ) Then
    Wscript.Echo "VB5 Installed"
End If

Open in new window

0
 
LVL 10

Accepted Solution

by:
Chad Smith earned 2000 total points
ID: 24093798
Check if a network file exists

Function FileExist(sTestFile As String) As Boolean
   'This function does not use DIR since it is possible that you might have
   'been in the middle of running DIR against another directory in
   'an attempt to match one directory against another.

   'It does not handle wildcard characters
   Dim lSize As Long
   On Error Resume Next
   'Preset length to -1 because files can be zero bytes in length
   lSize = -1
   'Get the length of the file
   lSize = FileLen(sTestFile)
   If lSize > -1 Then
      FileExist = True
   Else
      FileExist = False
   End If
End Function
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question