IcemanND Posted February 10, 2005 Posted February 10, 2005 Since I wrote DetectCD.exe I have had requests for a similar utility for removable drives. So I rewrote & renamed DetectCD to DetectDrive.It Now Detects all drive attached to a system (except A:) and creates a permanent environment variable.Usage: DetectDrive {options}Options:HELP Shows help this screen BACKSLASH Return value has backslash 'C:\', default is no backslash 'C:' REMOVABLE Create variable for all removable drives except A:, i.e usb, firewire, etc. REMOVABLE# FIXED Create variable for all fixed disk drives, FIXED# REMOTE Create Variable for all Remote or network drives, REMOTE# CDROM Create Variable for all CD-Rom drives, CDROM# RAMDISK Create Variable for all RamDrives, RAMDRIVE# ALL All variables will be created # will be replaced with a number corresponding to the order in which the drive is lettered starting with 1 for each group. DetectDrive Fixed CDROM Removable Backslash returns the following on my system in the environment variablesFIXED1=C:\ FIXED2=D:\ FIXED3=F:\ CDROM1=E:\ CDROM2=M:\ REMOVEABLE1=G:\You can use as many switches as desired. But at least one must be selected other than BACKSLASHEDIT: IMPORTANT NOTE: 4/7/2006You will not see the variables created until you open a new cmd window, but if you go to 'System Properties -> advanced -> environment variables' they should be listed there.Since the variables are directly written to the registry they are not available to the calling CMD script.DetectDrive.exe
GreenMachine Posted February 10, 2005 Posted February 10, 2005 Looks like someone has a kid keeping 'em up all night!I like the BACKXLASH option!Good work, IcemanND!
IcemanND Posted February 10, 2005 Author Posted February 10, 2005 I didn't want to have to rewrite it again just for people like you who don't like backslashes. Seems I am learning from the past.
jaclaz Posted March 17, 2005 Posted March 17, 2005 Nice little app, I would say!Unfortunately it seems like it is not working on my Windows 2K, maybe XP only?jaclaz
IcemanND Posted March 17, 2005 Author Posted March 17, 2005 Never tested it in 2K. All of my systems and clients use XP. I'll check it out next week when I can rebuild a system with 2K and see whats going on.
JPamplin Posted March 17, 2005 Posted March 17, 2005 This is nice, but I need to do something like this in DOS. Any ideas?JP
IcemanND Posted March 17, 2005 Author Posted March 17, 2005 As in dos 6 or from the CMDline in 2k or XP?
JPamplin Posted March 17, 2005 Posted March 17, 2005 Actual DOS, yes. Like Win98 Boot Disk DOS. How about it - have you created a DOS version?
IcemanND Posted March 17, 2005 Author Posted March 17, 2005 In short, NO. This program queries windows for the drive mappoints and then creates the environment variables.I don't know of a way to differentiate between drive tyes in DOS if someone knows a way I'd be glad to rewrite or assist in creating a dos version.
IcemanND Posted March 17, 2005 Author Posted March 17, 2005 you will not see the variables created until you open a new cmd window, but if you go to 'System Properties -> advanced -> environment variables' they should be listed there.Since the variables are directly written to the registry they are not available to the calling CMD script.
jaclaz Posted March 17, 2005 Posted March 17, 2005 Yes, ok, from a new command prompt they work in win2k too.But (as you said) they are persistent, so that if I issue the DETECTDRIVE ALLcommand with a Removable drive attached, then I re-boot without it, the REMOVABLE1=K:is still there (and I have to reset it manually).Same things obviously happen with the (fixed as seen by Windows) drive which is actually removable as it is in a removable tray, when I reboot without it and rerun the utility the drive is still there. Still have to try how it behaves when called from a batch file.All in all (don't take it as a critic, it is just a suggestion) I would prefer a non-persistent option, so that I don't have to reset all variables via batch.Another feature (I know I am asking a lot) could be to make the variable as a comma separated list, something like:FIXED=C:,D:,E:CDROM=F:,G:,H:REMOVABLE=K:So that the variable has not a progressive number.I already wrote a small batch that detects fixed and CD drives, if it is not a "secret of the trade" could you let me know how you detect the removable ones?Thanks,jaclaz
IcemanND Posted March 17, 2005 Author Posted March 17, 2005 I will work on the comma delimited list, shouldn't be too dificult once I find where I left the source code.As to removing the variables i can add a REMOVE switch which would parse the environment variables and remove all of the variables which it may have created. I won't say that it created because someone may create there own CDROM22 and it would be removed. I do not want to leave a log behind in the registry or a file. I could also make a REFRESH which would do the above and then create all new variables.Or a VERIFY which would check each variable and verify it was the right type and letter.Or maybe REMOVEMISSING to remove variables which no longer have properly associated drives.Asfar as the secret to determine drivetype I use to the DriveType Constants and Property of VB6. These are also available in vbscript as I recall.Unknown 0 Drive type can't be determined. Removable 1 Drive has removable media. This includes all floppy drives and many other varieties of storage devices. Fixed 2 Drive has fixed (nonremovable) media. This includes all hard drives, including hard drives that are removable. Remote 3 Network drives. This includes drives shared anywhere on a network. CDROM 4 Drive is a CD-ROM. No distinction is made between read-only and read/write CD-ROM drives. RAMDisk 5 Drive is a block of Random Access Memory (RAM) on the local computer that behaves like a disk drive.
jaclaz Posted March 18, 2005 Posted March 18, 2005 As far as the secret to determine drivetype I use to the DriveType Constants and Property of VB6. These are also available in vbscript as I recall.Thanks, IcemanD, I'll look into the VB specifications.About the problem of an user creating a CDROM22 variable, you could "personalize" the varianle names, such as:ICEMFIXEDICEMCDROMICEMREMOVABLEthis way it is unlikely that an user will make these variables.Cheers,jaclaz
os2fan2 Posted March 24, 2005 Posted March 24, 2005 I'm trying it under win2k, and it's doing nothing, either with the win2k or winxp version of the msvbvm60.dll. It does not set the variables under either 4nt or cmd. If i recall correctly, you can't set environment variables from an exe, only a batch. So what most people usually do under OS/2 or windows is to pass the output to a batch file, and then call the batch file.This would be quite handy under bartpe, because the environment changes in the registry is not passed through to started to later shells. You have to use something like nu2menumsg.exe to change the real-mode environment. Calling a batch file, eg setdrive.cmd, would allow you to query once and set in many sessions, eg detectdrive all > %temp%\drives.cmd, and then call drives.cmd whenever you want to find out who's where.W
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now