Jump to content
Sign in to follow this  
MooglePower

Unmounting Drives

Recommended Posts

MooglePower

I'm writing a script in which drives need to be mapped consistently to the same letter. Currently, my script will just return an error if I run it when something else is mapped, but I want to be able to have my program unmount any drive that may be mounted to that particular letter.

I know that there's the DriveMapDel function, but it only unmounts networked drives. Is there a way to unmount everything with that particular letter?

Share this post


Link to post
Share on other sites
Jos

Don't see how you can Unmount a drive that was never mounted in the first place.

The fixed drive letters and USB drive letters are assigned in the DiskManager which you can find in the Controlpanel.

Is that what you would want to change?


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
MooglePower

The drive would have been mounted when the end user plugged it into his computer, but it wouldn't have been mounted by the script.

Yes, system administrators have access to Disk Manager, but end users don't. I'm writing the script for an environment in which users do not have privileges (or the knowledge required) to go into Disk Manager and change the drive letters manually. That's why I have to script the unmount of any drives currently mounted on the desired drive letter before I go ahead and mount the network share that I need to mount.

Don't see how you can Unmount a drive that was never mounted in the first place.

The fixed drive letters and USB drive letters are assigned in the DiskManager which you can find in the Controlpanel.

Is that what you would want to change?

Share this post


Link to post
Share on other sites
MooglePower

If there's a way to change drive letters for pre-existing drives, that would work, too.

Share this post


Link to post
Share on other sites
Jos

Never done this but a quick google turned up this vbscript which should be pretty easy to convert to AutoIt3 code:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colVolumes = objWMIService.ExecQuery _
    ("Select * from Win32_Volume Where Name = 'D:\\'")
For Each objVolume in colVolumes
    objVolume.DriveLetter = "Q:"
    objVolume.Put_
Next

Some other nice code there: http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/disk/drives

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×