...

View Full Version : How to create exe file that detects a specific software on pc



janice_2k
05-07-2004, 11:01 AM
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 :thumbsup:

Thanks in advance,
Janice

sage45
05-07-2004, 05:27 PM
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-

the_bob
05-17-2004, 09:37 PM
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

the_bob
05-17-2004, 09:39 PM
nevermind, dont answer that

its sounds like a virus

Roy Sinclair
05-17-2004, 10:01 PM
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.

sage45
05-18-2004, 03:17 PM
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-

janice_2k
05-24-2004, 04:19 AM
Hi Sage,
Thanks for the codes and information. I got it running smoothly now. Really appreciate that. Thanks again. Have a nice day! :thumbsup:

Janice



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum