Mount/Unmount Fixed Disk Volumes

Discussion in 'Scripting' started by JackRazz, Jan 7, 2004.

  1. JackRazz

    JackRazz Guest

    JackRazz, Jan 7, 2004
    #1
    1. Advertisements

  2. DISKPART is the command you're looking for.

    DISKPART>
    LIST VOLUME <-- this will show F: as mapped to some volume ID #.
    SELECT VOLUME # <-- Use the volume ID # from the previous command
    REMOVE <-- this unmounts the selected volume, in this case, F: . Make sure
    you have nothing opened against F: or it will fail.
    SELECT VOLUME # <-- Use the volume ID # from the previous command
    ASSIGN MOUNT=<directory> <-- this mounts the selected volume to the given
    directory as mount point

    You can put the above into a script file and execute with DISKPART as well,
    assuming you can hard code correctly. I wrote a batch file to dynamically
    mount/unmount partitions based on drive label.

    The same thing can be accomplished via the DISKMGMT.MSC console as GUI.

    This works from XP to Longhorn.

    --
    //David
    IIS
    This posting is provided "AS IS" with no warranties, and confers no rights.
    //
    I have a dual boot WinXP system with the second WinXP on Drive F (NTFS). Is
    it
    possible to use WMI to mount and unmount this drive to reduce the chance of
    a virus
    infecting the backup?

    I've tried the script examples for mount/unmount from:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_logicaldisk.asp

    But no luck. If anyone has any code that might help me, I'd appreciate it.

    Thanks - JackRazz
     
    David Wang [Msft], Jan 10, 2004
    #2
    1. Advertisements

  3. JackRazz

    JackRazz Guest

    David,
    Thanks for this info. This is exactly what I was looking for. I looked at the Disk
    Manager snapin, but didn't see it. I didn't know the verb to look for (remove). Now
    I can be sure that the backup won't get infected if I get hit with a virus.

    Thanks - JackRazz


    | DISKPART is the command you're looking for.
    |
    | DISKPART>
    | LIST VOLUME <-- this will show F: as mapped to some volume ID #.
    | SELECT VOLUME # <-- Use the volume ID # from the previous command
    | REMOVE <-- this unmounts the selected volume, in this case, F: . Make sure
    | you have nothing opened against F: or it will fail.
    | SELECT VOLUME # <-- Use the volume ID # from the previous command
    | ASSIGN MOUNT=<directory> <-- this mounts the selected volume to the given
    | directory as mount point
    |
    | You can put the above into a script file and execute with DISKPART as well,
    | assuming you can hard code correctly. I wrote a batch file to dynamically
    | mount/unmount partitions based on drive label.
    |
    | The same thing can be accomplished via the DISKMGMT.MSC console as GUI.
    |
    | This works from XP to Longhorn.
    |
    | --
    | //David
    | IIS
    | This posting is provided "AS IS" with no warranties, and confers no rights.
    | //
    | | I have a dual boot WinXP system with the second WinXP on Drive F (NTFS). Is
    | it
    | possible to use WMI to mount and unmount this drive to reduce the chance of
    | a virus
    | infecting the backup?
    |
    | I've tried the script examples for mount/unmount from:
    |
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_logicaldisk.asp
    |
    | But no luck. If anyone has any code that might help me, I'd appreciate it.
    |
    | Thanks - JackRazz
    |
    |
    |
    |
    |
     
    JackRazz, Jan 13, 2004
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.