Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

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
0
vbbuff
Asked:
vbbuff
  • 4
  • 4
1 Solution
 
avya2kCommented:
is this setup program is self made or using third party software
0
 
List244Commented:
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
 
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
List244Commented:
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
 
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.
0
 
List244Commented:
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
 
vbbuffAuthor Commented:
do you know how to list244?
0
 
List244Commented:
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
 
vbbuffAuthor Commented:
Thanx list244

Very useful suggessions

bye..
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now