Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to create exe file that detects a specific software on pc

    Dear Gurus,
    I am new in VB. I would like to create an exe file to be stored in a CD, that will detect the PC for a specific software. If the software doesn't exist, it will ask user to install the software and prompt the software installation from the CD first, then only it will run other programmes in the CD. Otherwise, it will run other programmes/activities in the CD. How can I do so by using VB? Hope my description is not confusing and hope to get some reply soon. Any sample codes and suggestions are higher appreciated. Have a pleasant day

    Thanks in advance,
    Janice

  • #2
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,059
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Well,

    Detecting an application that is installed on a computer is easy... It all comes down to the method you want to use to detect the installation of the program... Here are a couple of the more common practices...

    Method One - Detecting using file existence.

    Dim objFSO As Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If Not objFSO.FileExists("c:\prgdir\myfile.dll") Then
    If Not objFSO.FileExists("d:\setup.exe") Then
    MsgBox "Missing d:\setup.exe" _
    & vbCrLf & "This application will not behave normally." _
    & vbCrLf & "It is recommened that the application be closed" _
    & vbCrLf & "and the issue resolved.", vbExclamation, "Critical Error!"
    Else
    Shell "d:\setup.exe"
    End If
    End If

    Method Two - Detecting using dll/ocx call.

    Dim strExists As String, objFSO As Object

    Private Declare Function LoadLibrary Lib _
    "kernel32" Alias "LoadLibraryA" _
    (ByVal lpLibFileName As String) As Long

    Private Declare Function GetProcAddress Lib _
    "kernel32" _
    (ByVal hModule As Long, _
    ByVal lpProcName As String) As Long

    Private Declare Function FreeLibrary Lib _
    "kernel32" _
    (ByVal hLibModule As Long) As Long

    Public Function LibPresent(ByVal DllName As String, ByVal FunctionName As String) As Boolean
    Dim FunctionAddr As Long
    Dim DLLHandle As Long
    DLLHandle = LoadLibrary(DllName)
    If DLLHandle <> 0 Then
    FunctionAddr = GetProcAddress(DLLHandle, FunctionName)
    FreeLibrary DLLHandle
    End If
    LibPresent = FunctionAddr <> 0
    End Function
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strExists = LibPresent("c:\prgdir\myfile.dll", "DLLCall")
    If strExists <> 0 Then Shell "d:\setup.exe"

    You can also use a method calling to the registry to check for installion information or other known program information...

    HTH,

    -sage-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #3
    New Coder
    Join Date
    Dec 2003
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i was looking for something like this too, but is there anyway to get a program to search a PC for the program then delete it? it'd be alot easier to just run a program off of a cd then manually searching your harddrive to find and delete it

  • #4
    New Coder
    Join Date
    Dec 2003
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nevermind, dont answer that

    its sounds like a virus

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The command DEL has an option /S which can be used to delete all files specified from all subdirectories on a single drive, it wouldn't be hard to write a script that would do the same for all drives on a computer but it would indeed be a dangerous tool and for most programs the right way to uninstall them is via the Add/Remove Programs tool in the Control Panel.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #6
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,059
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Progmatically, however, you could write a script that would search the registry for the uninstall information of the program...

    This would be easy, as you should know either, the GUI ID or KeyName that the program creates in the uninstall portion of the registry...

    [HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall]

    From there you would grab the information from UninstallString Key and plug it into a shell command...

    HTH,

    -sage-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #7
    New Coder
    Join Date
    Apr 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Sage,
    Thanks for the codes and information. I got it running smoothly now. Really appreciate that. Thanks again. Have a nice day!

    Janice


  •  

    Posting Permissions

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