View Full Version : Detecting removable drives
NewsArchive
03-29-2013, 08:57 AM
I must create an installer to detect whether the target is a removable USB
memory device or their actual hard drive.
Is there some sample code available to show me how to do this?
The installer may have tens of thousands of uses so hopefully something
detailed and stable.
But I am expecting that it is probably just some option in an aready
available function!
Thank you,
Mike
NewsArchive
03-29-2013, 10:10 AM
Mike,
> I must create an installer to detect whether the target is a removable USB
> memory device or their actual hard drive.
>
> Is there some sample code available to show me how to do this?
>
> The installer may have tens of thousands of uses so hopefully something
> detailed and stable.
>
> But I am expecting that it is probably just some option in an aready
> available function!
What you can try is:
1. Use the "Get System Info (Enumerate Disk Drives)" script function to
retrieve a LIST that specify all valid drives in the system.
2. LOOP through the LIST (see "Handle String Operation" function -> List
Item) to get the items from the list.
3. Use "Get System Info (Drive Type)" function to check if the item is a
hard drive (e.g. if it returns $DRIVE_FIXED$ then the item is a hard drive).
Friedrich
NewsArchive
03-29-2013, 12:47 PM
Thank you. Will give it a try.
MIke
NewsArchive
03-29-2013, 12:47 PM
You have to enumerate & process drives just to see where the setup is
running from? Couldn't you just do #3 on CURDIR?
Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
I'll search help files & Google for you.
NewsArchive
03-29-2013, 12:48 PM
Also, if the user mounts the USB drive as an NTFS folder, then what
happens?
Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
I'll search help files & Google for you.
NewsArchive
03-29-2013, 12:48 PM
You only have to enumerate if you would like to find all removable drives
(e.g. to display fixed drives in a combo and then only offer those drives as
a valid target). It's also possible to check the drive after the user
selected the installation folder. In this case, there is no need to
enumerate.
Friedrich
NewsArchive
04-01-2013, 03:08 AM
If the USB drive was mounted under an NTFS folder, (e.g.
"C:\YadaYada\MyUSBDrive") would there be a way via SetupBuilder to
detect that it's not part of drive C and that the actual target is a
USB drive?
Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
I'll search help files & Google for you.
NewsArchive
04-01-2013, 03:09 AM
Do you just sit in your basement trying to make trouble????? <g>
I've normally used GetDriveTypeA, but that requires a drive letter.
This link has some back-and-forth argument about detecting USB drives:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364939%28v=vs.85%29.aspx
and whether SetupDiGetDeviceRegistryProperty is a valid approach.
And I've seen Windows disk management decide that a USB-attached external
hard drive was a local drive rather than a "removable" drive.
Where's Lee with his Advil bottle?????
jf
NewsArchive
04-01-2013, 03:10 AM
Jane,
> Where's Lee with his Advil bottle?????
Sorry, ran out. Will generic ibuprofen suffice?!<g>
Lee White
NewsArchive
04-01-2013, 03:10 AM
Yep!
Thanks!!
Jane Fleming
NewsArchive
04-01-2013, 09:32 AM
Amateurs!
--
Russ Eggen
RADFusion International, LLC
NewsArchive
04-01-2013, 01:03 PM
Jane,
> Yep!
> Thanks!!
Anytime!!!
--
Lee White
RPM Report Viewer.: http://www.cwaddons.com/products/rpm/
RPM Review........: http://www.clarionmag.com/cmag/v11/v11n06rpm.html
Report Faxing.....: http://www.cwaddons.com/products/afe/
---Enroll Today---: http://CWaddons.com
Enhanced Reporting: http://CreativeReporting.com
Product Release & Update Notices
http://twitter.com/DeveloperPLUS
Windows 8 brings us "The Oval, Bumper Car, Roller Coaster of Wait!"
NewsArchive
04-01-2013, 01:04 PM
Russ Eggen,
> Amateurs!
Back in the day but I always preferred Jack or Scotch!<g>
And as all good Scott's know... "Feed it!"
<http://youtu.be/8a7tUusVXM0>
--
Lee White
RPM Report Viewer.: http://www.cwaddons.com/products/rpm/
RPM Review........: http://www.clarionmag.com/cmag/v11/v11n06rpm.html
Report Faxing.....: http://www.cwaddons.com/products/afe/
---Enroll Today---: http://CWaddons.com
Enhanced Reporting: http://CreativeReporting.com
Product Release & Update Notices
http://twitter.com/DeveloperPLUS
Windows 8 brings us "The Oval, Bumper Car, Roller Coaster of Wait!"
NewsArchive
04-01-2013, 01:05 PM
<bg>
I was just too lazy to *pick* a good scotch then find an image. So many
choices! I'll defer to Stamos <vbg>.
--
Russ Eggen
RADFusion International, LLC
NewsArchive
04-01-2013, 01:06 PM
Ha! I don't have a basement.<g>
Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
I'll search help files & Google for you.
NewsArchive
04-01-2013, 01:06 PM
Jeff Slarve,
> Ha! I don't have a basement.<g>
Well, there's your problem!!!
--
Lee White
RPM Report Viewer.: http://www.cwaddons.com/products/rpm/
RPM Review........: http://www.clarionmag.com/cmag/v11/v11n06rpm.html
Report Faxing.....: http://www.cwaddons.com/products/afe/
---Enroll Today---: http://CWaddons.com
Enhanced Reporting: http://CreativeReporting.com
Product Release & Update Notices
http://twitter.com/DeveloperPLUS
Windows 8 brings us "The Oval, Bumper Car, Roller Coaster of Wait!"
NewsArchive
04-03-2013, 01:15 AM
Hi Friedrich -
Did you see that post?
>If the USB drive was mounted under an NTFS folder, (e.g.
>"C:\YadaYada\MyUSBDrive") would there be a way via SetupBuilder to
>detect that it's not part of drive C and that the actual target is a
>USB drive?
>
Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
I'll search help files & Google for you.
NewsArchive
04-03-2013, 07:38 AM
Hi Jeff,
> If the USB drive was mounted under an NTFS folder, (e.g.
> "C:\YadaYada\MyUSBDrive") would there be a way via SetupBuilder to
> detect that it's not part of drive C and that the actual target is a
> USB drive?
The "Get System Info (Drive Type)" SetupBuilder function is a wrapper around
the GetDriveType Windows API. It does not always reflect accurate results
(especially for USB devices).
The installer runtime internally already makes use of the DeviceIoControl
Windows API to handle the following feature (introduced in 7.7 Build 3705 --
May 31, 2012)
---
IMPROVEMENT: Installer: The "Get System Info (Volume System Name)" function
returns a list of items in variable %_SB_RETURNEX% separated
by a vertical bar ("|"). List item #1 represents the name of
the specified volume, item #2 represents the serial number of
the specified volume, item #3 represents the device number and
item #4 represents the partition number (if the device can be
partitioned; otherwise, it is -1).
---
I have to check whether it is possible to add an option to read the
"MediaType" via DeviceIoControl.
Friedrich
NewsArchive
04-03-2013, 09:46 AM
Hi Friedrich,
> The "Get System Info (Drive Type)" SetupBuilder function is a wrapper around
> the GetDriveType Windows API. It does not always reflect accurate results
> (especially for USB devices).
>
> The installer runtime internally already makes use of the DeviceIoControl
> Windows API to handle the following feature (introduced in 7.7 Build 3705 --
> May 31, 2012)
I haven't looked for this particular thing, but I think you may be able to
use WMI (Windows Management Instrumentation) to query the OS for more
detailed information.
Best regards,
--
ArnĂ³r Baldvinsson - Icetips Alta LLC
Port Angeles, Washington
www.icetips.com - www.buildautomator.com - www.altawebworks.com
Icetips product subscriptions at http://www.icetips.com/subscribe.php
NewsArchive
04-03-2013, 09:47 AM
Thanks Friedrich
Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
I'll search help files & Google for you.
NewsArchive
06-22-2013, 05:57 AM
FYI: we have added a new function to SetupBuilder to detect USB devices.
This will be available in the upcoming maintenance release.
Friedrich
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.