Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you run an exe program or launch a .BAT file from a Cddrive,ect

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, before I address my question I just want to say you guys are the best. My question is similar to an earlier posting. Here it is, OK, you guys have show us how we can
run and exe program and batch file, using this code.
dim Myapp
myApp=Shell("d:\Program Files\Macromedia\Flash 5\Flash.exe", 1)

Ok my question is, how can I get VB to search for an
exe program(example a setup.exe) on a cd-drive,zip drive,orhard drive.
Now a-days many of us have two cd-drives and multiple partitions thus having VB search for a specific file would be helpful.
thanks..
 
example :

Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA"
(ByVal nDrive As String) As Long

Private Sub Command1_Click()
On Error Resume Next
Dim lngDriveType As Long
Dim strDrive As String
Dim strFile As String
Dim blnCdFound As Boolean
blnCdFound = False
strFile = "\CD\CD_OPEN.EXE"
For i = Asc("a") To Asc("z")
lngDriveType = GetDriveType(Chr(i) & ":")
If lngDriveType = 5 Then 'cd-drive
strDrive = Chr(i) & ":"
strRet = Dir(strDrive & strFile)
If Err.Number > 0 Then
strRet = ""
Err.Clear
End If
If strRet <> &quot;&quot; Then
'cd gevonden
blnCdFound = True
Exit For
End If
End If
Next i
If blnCdFound Then
ret = Shell(strDrive & strFile, vbNormalFocus)
Else
MsgBox &quot;Leg de juiste cd in 1 van de cd drives&quot;
End If
End Sub

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX.

Download Demo version on my Site:
Promotions before 02/28/2001 (free source codebook),visite my site
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top