JerryD Posted January 18, 2007 Posted January 18, 2007 Hi all, Trying to script unmounting and then remounting a drive. I've like to use WMI and have been digging around there but haven't found anything yet. Anyone have any experience with this? TIA! Jerry
herewasplato Posted January 18, 2007 Posted January 18, 2007 Will Net Use not work for you? [size="1"][font="Arial"].[u].[/u][/font][/size]
JerryD Posted January 18, 2007 Author Posted January 18, 2007 Will Net Use not work for you?I should have been clearer. I meant a physically connected drive - IDE, SATA, USB.
Danny35d Posted January 18, 2007 Posted January 18, 2007 I don't know anything about WMI, but this script done by SolidSnake use subst command line. It may give you and idea. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
JerryD Posted January 18, 2007 Author Posted January 18, 2007 Once again - I'm trying to dismount and mount a physical hard drive. Specifically, when rebuilding a a machine with a second hard drive PHYSICALLY attached - either by IDE, SATA, USB, or Fire Wire - I want to make that drive unavailable during a specific routine and then make it available again. I don't understand how SUBST would apply, but I'm slow today!
herewasplato Posted January 18, 2007 Posted January 18, 2007 I should have been clearer. I meant a physically connected drive - IDE, SATA, USB.Ahhh, you did say drive and not share... I should have caught that.I was wondering about your desire to use WMI because I knew that you knew about Net Use. Maybe a WMI guru will stop by soon.-MSP- [size="1"][font="Arial"].[u].[/u][/font][/size]
Danny35d Posted January 18, 2007 Posted January 18, 2007 Sorry that I miss understand you, English is my second language I know you are looking for WMI script, but in case that you don't found any you can use diskpart (assing, remove) switches as a work around.This is a nice udf from dem3treMicrosoft TechNet AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
JerryD Posted January 19, 2007 Author Posted January 19, 2007 (edited) Sorry that I miss understand you, English is my second language I know you are looking for WMI script, but in case that you don't found any you can use diskpart (assing, remove) switches as a work around.This is a nice udf from dem3treMicrosoft TechNetThanks Danny35d. The UDF is really nice, but unfortunately not only does it not have anything for dismounting a drive, I've tried diskpart and for whatever reason it's not working, which is why I thought WMI might be better suited.Actually, it occurs to me that the drive(s) in question are almost always in an IDE or SATA drive bay on a laptop or connected via a USB or FireWire to IDE/SATA adapter, and these devices always appear in the "Safely Remove Hardware" list when you double click the (PCMCIA/Arrow) icon in the system tray. It also occurs to me that when you do stop (disable? dismount) one of these drives, the only way (I'm aware of) to get the drive to be available again is to unplug and then replug it.Thanks again all for your help. Edited January 19, 2007 by JerryD
Danny35d Posted January 19, 2007 Posted January 19, 2007 (edited) It also occurs to me that when you do stop (disable? dismount) one of these drives, the only way (I'm aware of) to get the drive to be available again is to unplug and then replug it.I was about to recommend Devcon, but you are right. You will need to unplug and then replug it. I don't know how to use diskpart_UDF, but you can do this steps manually and then try to come up with the script.1) Attach usb drive and open windows explorer "MY Computer" the window where you can see all the drives letters:2) open command prompt CMD.3) type diskpart4) type list volume5) type select volume 3 (volume 3 is the one which has the usb drive letter that you want to unmount)6) type remove (Once return successfully removed you will see on the windows explorer the drive letter is gone)7) type assing (Once return successfully assigned You will see on the windows explorer the drive letter reappear)Hope this help. Edited January 19, 2007 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
JerryD Posted January 19, 2007 Author Posted January 19, 2007 I was about to recommend Devcon, but you are right. You will need to unplug and then replug it. I don't know how to use diskpart_UDF, but you can do this steps manually and then try to come up with the script.1) Attach usb drive and open windows explorer "MY Computer" the window where you can see all the drives letters:2) open command prompt CMD.3) type diskpart4) type list volume5) type select volume 3 (volume 3 is the one which has the usb drive letter that you want to unmount)6) type remove (Once return successfully removed you will see on the windows explorer the drive letter is gone)7) type assing (Once return successfully assigned You will see on the windows explorer the drive letter reappear)Hope this help.You lost me at step 7 - what's "assing"?
Danny35d Posted January 19, 2007 Posted January 19, 2007 Another option is using Mountvol.exe.Like Joon mention is another option.Trying to script unmounting and then remounting a driveYou first post said you want to unmount (remove) and then after you done doing some staff remount (assign).Basically diskpart remove switch is to unmount or remove drive letter from the select volume and assign switch is to mount or assing drive letter to the selected volumen. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
JerryD Posted January 19, 2007 Author Posted January 19, 2007 (edited) Joon - THANKS! MountVol is perfect! It will be a bit tricky to grab the volume name, but dem3tre's excellent DiskPart UDF should be really helpful in setting up some functions for MountVol.Danny35d - got it now. Thanks for your help with diskpart's syntax. OH YEA - RoboCopyGUI is very cool too! Edited January 19, 2007 by JerryD
Danny35d Posted January 19, 2007 Posted January 19, 2007 Your welcome, the only issue I can see with Mountvol.exe, I could be wrong. I think you will be able to unmound a drive, but won't be able to mounted back. You may need to unplug the usb and plug it back. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
JerryD Posted January 19, 2007 Author Posted January 19, 2007 Your welcome, the only issue I can see with Mountvol.exe, I could be wrong. I think you will be able to unmound a drive, but won't be able to mounted back. You may need to unplug the usb and plug it back.Well I'm happy to say you're wrong! But that's COOL!! The only thing is grabbing the right drive, but that shouldn't be too hard. With the drive connected, when you run MountVol /L, the second hard drive is listed like this: \\?\Volume{a4f956a1-fea4-11d9-88a3-806d6172696f}\ D:\ Then when you run MountVol D:\ /D, the drive is listed like this: \\?\Volume{a4f956a1-fea4-11d9-88a3-806d6172696f}\ *** NO MOUNT POINTS *** Then running MountVol D:\ \\?\Volume{a4f956a1-fea4-11d9-88a3-806d6172696f}\ remounts the drive. This all happens just about instantly! Thanks again to all for your help.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now