?
Solved

finding the drive from which setup was run

Posted on 2003-03-26
9
Medium Priority
?
162 Views
Last Modified: 2010-05-01
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
0
Comment
Question by:vbbuff
[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
  • 4
  • 4
9 Comments
 
LVL 5

Expert Comment

by:avya2k
ID: 8215461
is this setup program is self made or using third party software
0
 
LVL 8

Expert Comment

by:List244
ID: 8215666
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
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

0
 
LVL 3

Author Comment

by:vbbuff
ID: 8217984
  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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Expert Comment

by:List244
ID: 8221307
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
0
 
LVL 3

Author Comment

by:vbbuff
ID: 8232605
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.
0
 
LVL 8

Expert Comment

by:List244
ID: 8232917
alright
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
0
 
LVL 3

Author Comment

by:vbbuff
ID: 8233155
do you know how to list244?
0
 
LVL 8

Accepted Solution

by:
List244 earned 1000 total points
ID: 8233832
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
1
    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)
    Else
        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
0
 
LVL 3

Author Comment

by:vbbuff
ID: 8234292
Thanx list244

Very useful suggessions

bye..
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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
Course of the Month12 days, 13 hours left to enroll

777 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