I am writing a USB driver to a product which is basically a USB pen drive. Upon connecting the product to the usb port, I want to see the drive name/volume name as "XXXX Corporation". I see that by default it always gets shown as "Removable Disk" in Windows explorer or my computer.
If I use any USB detail reader tools available in the net, then I can see the vendor id and manufacturer ids and other usb details. Renaming the drive from windows works but I want this to happen by default without asking the end user to rename. Having autorun.inf in root of the drive works only on WindowsXP.
How do I get this? Are there any descriptors which needs to be coded explicitly in my usb drivers stack? There are already API's to obtain the manufacturer/Product/Serial descriptors in my usb drivers stack.
Thanks in advance.
Chandra
The name shown in file explorers is the filesystem label, it's not a USB descriptor. The tool you are using to create the filesystem (whether FAT or NTFS) probably allows you to set the label. It can also be changed on an existing filesystem. The label can also be read on any operating system.
The label entry of the autorun.inf file should also be read by modern Windows. Some Linux file explorers (Gnome's Nautilus) might use it if it's there, but the cross-platform way is the filesystem label.
Related
I would like to create a USB stick with a simple HTML file in it which opens when the stick gets plugged in. It is meant to be some kind of merchandise thing. Thing is that I read that Microsoft disabled Autorun on Windows 7 for security reasons. But despite that I have such a USB stick lying around which does the exactly the thing I'm looking for. Unfortunately it is not displayed as a removable drive, therefore I can not take a look into it.
Can anyone recommend a method, which works on as many devices (with different OS, different Settings) as possible?
i think you are searching for the autorun.inf http://en.wikipedia.org/wiki.Autorun.inf
you can write your own autorun.inf and copy it on the stick (if it does not show up as removable disk format it, maybe run a data rescue tool first) if this will work depends on the os settings of the specific computer you plug in the stick. if autorun is disabled in the os it will not work...
I have a tedious project coming up. I need to insert an USB flash drive into a computer, then copy over three files to that drive, and then unmount it and repeat 3000 times (literally). I was hoping to come up with some VBScript that can reduce my actions to just
insert the USB flash drive,
double click on the .vbs file,
remove the USB flash drive.
I figure it isn't too difficult to come up with the copy and paste part of the code as long as I am inserting the USB into the same port every time. Is this assumption correct? However, the real problem is unmounting/ejecting the USB drive. Is there any simple VB Script code that can accomplish this?
This was the first Google result for vbscript unmount: Unmounting USB drives
This worked on Windows 7 if the script is run elevated (as an Administrator):
Set shell = WScript.CreateObject("WScript.Shell")
shell.Run "mountvol <drive>: /d"
mountvol is included with Windows.
You could probably even reduce the input needed by polling the drive letter that your USB sticks mount to, and if there is a drive present, copy the files over and then unmount.
Since you're doing this with a thumbdrive, you can put DevCon on it and use DevCon to eject the drive..
http://support.microsoft.com/kb/311272
or you can also try DevEject
http://translate.google.com/translate?u=http://www.withopf.com/tools/deveject/&langpair=de%7Cen
My answer is not very much related but if you are willing to use Linux I would have a full software stack for exactly that. What it does is to hook into the Linux udev system and automatically formats USB pen drives that get connected to certain USB ports, then copies files to the drive, unmounts the drive and informs the user.
We used this to copy data to 500+ merchandise USB pen drives.
The best option I can find is this:
1) open a shell and run mountvol and locate GUID
\\?\Volume{1be3da43-6602-11e0-b9e6-f11e1c50f5b5}\
F:\
2) execute mountvol /p [GUID] in script
Dim eject
Set eject = WScript.CreateObject("WScript.Shell")
eject.Run "mountvol \\?\Volume{1be3da43-6602-11e0-b9e6-f11e1c50f5b5}\ /p"
Set eject = Nothing
The only problem with this method is that it needs administrator access to remove the drive letter. If called by a user it will unmount the drive, in this case leaving an F: phantom. It is safe to remove the USB drive, or you can eject the phantom to remove it.
I had a usb flash drive which had data and was using FAT32 file table, till yesterday!
I had been using it only in Windows. Now when I plugin the usb flash drive, Windows XP reports the file system as RAW and trying to access the drive asks to format the drive. I desperately need to get some data out from there (the backup is a few days old).
I've already used a dozen of programs under windows that claim to read RAW data, but none has worked yet. Is there any script, utility or program under FreeBSD or Windows that will aid me in getting that data back? If I plugin the usb drive to my FreeBSD box it only appears as /dev/da0, so I cannot mount it.
Apologies if I am not making sense, but is there any light at the end of the tunnel?
You can use dd to make a raw copy:
dd if=/device of=target_file
After that, you may want to google for "data carving", and use a program such as foremost.
We have an auto update for our software that is installed via USB key (with the auto run). If I wanted to ensure that only authorized USB Keys were used, what's the best way?
Our installer is already signed, and it won't run otherwise. But I'm more wanting to inspect the USB Key for a signed installer, and if it's not there, just ignore, or even "Eject" the USB device.
And I should be able to tell the difference (in code) between a usb storage device, and say a camera, or keyboard.
I'm only wanting to disable non-authorized storage devices.
Thank you for your ideas.
non-authorized storage devices? This depends on how secure you want it to be. For the most secure level, it would consist of:
special firmware written to the flash drive to get extra "meta info" (read: expensive custom manufacturing of flash drives)
special windows driver to read that meta info from the flash drive
your program talking to that device driver to confirm it's authorized.
Or to the least secure level you have these options:
using a hidden file and a special key(possibly hashed time of last filesystem modification or something?) (dd breakable)
dropping below the filesystem level and recreating your own very simple filesystem.. (more security through obscurity though and dd could break that)
Also, for the "most secure" option, you really need a more secure way of running the program than auto-run and a device driver(which could be half-baked to make anything appear authorized). Why do you want it to only update from an authorized flash drive anyway?
You might be able to read the USB drive's serial number (assuming you get USB drives that have serial numbers; not all do). Then your application could call home to get the latest list of authorized serial numbers, and check to see if there is a match.
Earlz response is good, though I don't think you'd need custom manufacturing of flash drives... you would just need flash drives with some sort of unique firmware encrypted identifier. Perhaps something in the Kingston Data Traveler Line might do the trick. (I've never actually used one of these encrypted usb sticks, so I'm a bit foggy on the actual implementation details).
I'm need to find a method to programmatically determine which disk drive Windows is using to boot. In other words, I need a way from Windows to determine which drive the BIOS is using to boot the whole system.
Does Windows expose an interface to discover this? With how big the Windows API is, I'm hoping there is something buried in there that might do the trick.
Terry
p.s. Just reading the first sectors of the hard disk isn't reveling anything. On my dev box I have two hard disks, and when I look at the contents of the first couple of sectors on either of the hard disks I have a standard boiler plate MBR.
Edit to clarify a few things.
The way I want to identify the device is with a string which will identify a physical disk drive (as opposed to a logical disk drive). Physical disk drives are of the form "\\.\PHYSICALDRIVEx" where x is a number. On the other hand, a logical drive is identified by a string of the form, "\\.\x" where x is a drive letter.
Edit to discuss a few of the ideas that were thrown out.
Knowing which logical volume Windows used to boot doesn't help me here. Here is the reason. Assume that C: is using a mirrored RAID setup. Now, that means we have at least two physical drives. Now, I get the mapping from Logical Drive to Physical Drive and I discover that there are two physical drives used by that volume. Which one did Windows use to boot? Of course, this is assuming that the physical drive Windows used to boot is the same physical drive that contains the MBR.
Go into Control Panel
System and Security
Administrative Tools
Launch the System Configuration tool
If you have multiple copies of Windows installed, the one you are booted with will be named such as:
Windows 7 (F:\Windows)
Windows 7 (C:\Windows) : Current OS, Default OS
Unless C: is not the drive that windows booted from.Parse the %SystemRoot% variable, it contains the location of the windows folder (i.e. c:\windows).
You can use WMI to figure this out. The Win32_BootConfiguration class will tell you both the logical drive and the physical device from which Windows boots. Specifically, the Caption property will tell you which device you're booting from.
For example, in powershell, just type gwmi Win32_BootConfiguration to get your answer.
That depends on your definition of which disk drive Windows used to boot. I can think of 3 different answers on a standard BIOS system (who knows what an EFI system does):
The drive that contains the active MBR
The active partition, with NTLDR (the system partition)
The partition with Windows on it (the boot partition)
2 and 3 should be easy to find - I'm not so sure about 1. Though you can raw disk read to find an MBR, that doesn't mean it's the BIOS boot device this time or even next time (you could have multiple disks with MBRs).
You really can't even be sure that the PC was started from a hard drive - it's perfectly possible to boot Windows from a floppy. In that case, both 1 and 2 would technically be a floppy disk, though 3 would remain C:\Windows.
You might need to be a bit more specific in your requirements or goals.
You type diskpart, list disk and check disks for boot.
Ex:
dispart
list disk
select disk 0
detail disk
The disk with Boot volume is disk with windows installed:
There is no boot.ini on a machine with just Vista installed.
How do you want to identify the drive/partition: by the windows drive letter it is mapped to (eg. c:\, d:) or by how its hardware signature (which bus, etc).
For the simple case check out GetSystemDirectory
Try HKEY_LOCAL_MACHINE\SYSTEM\Setup\SystemPartition
You can try use simple command line. bcdedit is what you need, just run cmd as administrator and type bcdedit or bcdedit \v, this doesn't work on XP, but hope it is not an issue.
Anyway for XP you can take a look into boot.ini file.
a simpler way
search downloads in the start menu and click on downloads in the search results to see where it will take you the drive will be highlighted in the explorer.
On Windows 10.
Open "Computer Management"
Look for "Storage" in list "left top side of page"
select "Disk Management"
On section of page showing the list of disks and the partitions find the disk that has the partition assigned as drive C:
On that disk containing C: partition
Use the right mouse button to select the Square section containing The Disk Number, Type of drive and size in GB . When menu opens select the Properties.
A window will open showing what drive hardware was used.