finding the drive from which setup was run

Is there any way of finding from which drive the setup program was run?

wether the set-up was run from the hard-disk or CD drive & the drive path
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

is this setup program is self made or using third party software
Im assuming you mean self-made

Option Explicit

Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Command1_Click()
Dim DriveT As String, DriveLetter As String
DriveLetter = Left(App.Path, 3)
DriveT = GetDriveType(DriveLetter)
If DriveT = 2 Then DriveT = "Floppy Drive": GoTo 1
If DriveT = 3 Then DriveT = "Hard-Disk": GoTo 1
If DriveT = 4 Then DriveT = "Remote Drive": GoTo 1
If DriveT = 5 Then DriveT = "Cd-Rom Drive": GoTo 1
MsgBox "Setup is on " & DriveLetter & " which is a " & DriveT
End Sub

Okay this gets the letter from app.path
then gets the drive type and converts it from its integer form to string form

vbbuffAuthor Commented:
  Thanks for your comments.

   I have created a program which i'll be distributing in a CD. Now the program needs large amount of text data in form of Word Documents & also GIF & JPG Images. This I do not want to distribute on the client machine as it take huge amount of space. So I want the program to read data from the CD (or the Hard disk if the contents of the CD is copied to the Hard Disk and the Setup is run from the Hard Disk)
   For this reason I want to know from which drive the setup program was intalled so that I can make my program to access the files in that particular drive.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

So you want to know where it was installed from, not where its installing from?
In that case, id suggest creating an autorun.exe, that then runs when the cd is inserted, then it does

SaveSetting "APPNAME", "DEFAULT", "Install", "left(app.path,3)"

then whenever your program needs to know what drive use GetSetting to check
vbbuffAuthor Commented:
Hi everyone,

Sorry for my late response.

Dear List24, I want a foolproof method , since if the end computer has disabled auto-run then thi method might not work.
I think it should be possible by some deployment scripts.
One: You could write your own setup
Two: Check all cd drives for it(always)
Three: Have the setup open your program which saves the directory on first run
Four: Force them to show you the install folder on first run, after its been run once use savesetting to write to registry, readsetting to check if its first run

Those are basically your options
vbbuffAuthor Commented:
do you know how to list244?
For number one, you kind of have to know something like c++

For Number 2 you simply use the code i gave earlier and if its cd check if its the right one, if not check any other cd drive (this forces them to install by cd though)

For number three, you would have to have a setup program that will load your program after installing, then have your program on first run log its drive.

For number 4, the better of the ways:

Private Sub Form_Load()
Dim FileName As String, AlreadyRan As Boolean
AlreadyRan = GetSetting("YOURAPPNAME", "Data", "Ran", 0)
If AlreadyRan = False Then
    FileName = ShowOpen(Me.hWnd, "*.dat", "Please locate the install.dat file", False)
    If LCase(Right(FileName, 11)) = "install.dat" Then
        SaveSetting "YOURAPPNAME", "Data", "Ran",1
        SaveSetting "YOURAPPNAME", "Data", "Drive", left(filename,3)
        If FileName = "" Then End
        GoTo 1
    End If
End If
End Sub

That forces them to give you the install.dat, you can change the file if needed, if they later run the program, and it cant find the file you would simply give them like a yes/no msgbox saying something like file not found are you sure the cd is in, if they press no force them to tell you where install.dat is again (or some other file on the cd)

That is how you would do Number 4

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vbbuffAuthor Commented:
Thanx list244

Very useful suggessions

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.