Welcome, Guest. Please login or register.
May 20, 2013, 09:27:46 AM
Pages: [1]   Go Down
  Print  
Author Topic: Mount/Unmount a drive letter via command prompt in Windows?  (Read 5449 times)
rrussell
Ace

Posts: 3,306

Join Date: Jul, 2004


« on: July 06, 2007, 05:31:10 PM »

Intuit - this one's for you Wink

I'd like to duplicate (under XP Pro) going to the Device Manager->Drive Management and removing the drive letter from my CD drive, by sticking it into a command file that I can doubleclick and run.  And then similarly, I'd like to reassign it with another click.

Any advice?
Logged
rrussell
Ace

Posts: 3,306

Join Date: Jul, 2004


« Reply #1 on: July 06, 2007, 06:15:50 PM »

Aha, ok, I found "Diskpart" which you can hand a script file to.  So if my script file contains...

--
SELECT Volume 0
REMOVE
--

Then it'll remove the drive letter from volume 0 (happens to be my CDRom)

And then if I have a script file containing

--
SELECT Volume 0
ASSIGN
--

... then it puts it back.

Anyone got anything better?
Logged
MrbLOB9000
Ace

Posts: 12,896

Join Date: Apr, 2002


« Reply #2 on: July 09, 2007, 04:37:47 AM »

I don't have any advice on how to do this, but I'm to curious not to ask wtf you need this for?  I can't think of any reason to want this!
Logged
Intuit
Ace

Posts: 10,355

Join Date: Oct, 2002


« Reply #3 on: July 10, 2007, 05:38:47 AM »

You actually taught me something RRussell.
A long time ago I went through most of the utilities on XP Home like "Utility /?".  Well in DiskPart's case, the output was
Code:
Microsoft DiskPart version 5.1.3565

Copyright (C) 1999-2003 Microsoft Corporation.
On computer: UNKNOWNU

Microsoft DiskPart syntax:
        diskpart [/s ] [/?]

        /s  - Use a DiskPart script.
        /?          - Show this help screen.

Redundant/useless huh?  Not knowing or realizing it had an internalized commandline interface I quickly moved on.

In this situation I would've scripted the DEVCON DISABLE {DEVICE_ID} and accomplished what you did by disabling the drive hardware.

.
.
MrbLOB9k's inquiry, if AutoInsertNotification or rather, AutoRun is disabled, some programs fail recognize that the disc has been removed/changed and this causes minor issues until the volume is manually refreshed.

Using imagination another thought is maybe some program he's using runs only when the media is under an expected drive-letter.  Removing the volume then allows him to assign a virtual drive to take the place of the letter.
Logged
OldDummy
Sudhian Forum Moderator

Posts: 2,542

Join Date: Jun, 2005


Hey, thats not me.


« Reply #4 on: July 10, 2007, 03:00:37 PM »

now I've done it! I just ran diskpart /? /s and it asked for permission and then showed a model box and vanished.

Did I do anything permanent?
OD
Logged
Intuit
Ace

Posts: 10,355

Join Date: Oct, 2002


« Reply #5 on: July 10, 2007, 03:44:12 PM »

Presumably it would've "read" a (nul) file named "/?" Huh
If we don't see you around for awhile then we know it probably did do something.  Wink
Your guess is as good as mine...
Logged
rrussell
Ace

Posts: 3,306

Join Date: Jul, 2004


« Reply #6 on: July 10, 2007, 03:57:35 PM »

Quote from: "MrbLOB9000" date="1183970267"
I don't have any advice on how to do this, but I'm to curious not to ask wtf you need this for?  I can't think of any reason to want this!

Intuit was pretty much spot-on...

I have some software that I use to backup game discs and play games from a virtual drive.  (I've found this very very valuable with curious toddler fingers and a chewing teething infant about.)

It turns out that FEAR detects this and forces me to use the original physical disc in the original physical drive... UNLESS... I disable the physical drive. Then all is just peachy fine.

So my script will disable the physical drive, run the game, then re-enable the drive again.

(sits back and waits to see if a mod will mod this post...)
Logged
Intuit
Ace

Posts: 10,355

Join Date: Oct, 2002


« Reply #7 on: July 10, 2007, 05:29:37 PM »

http://www.snapfiles.com/reviews/Toddler_Keys/toddlerkeys.html

also helps with the little tikes...

Even though older kids may not loose or scratch the discs (as much)... boy they still like to finger-print them to death.  Even though I don't use them anymore that's still pretty much a pet-peeve.
Logged
rrussell
Ace

Posts: 3,306

Join Date: Jul, 2004


« Reply #8 on: July 10, 2007, 05:55:04 PM »

Quote from: "Intuit" date="1184102977"

Hah! That's awesome!

Thanks!
Logged
OldDummy
Sudhian Forum Moderator

Posts: 2,542

Join Date: Jun, 2005


Hey, thats not me.


« Reply #9 on: July 10, 2007, 07:35:35 PM »

Toddlerkeys heck, this will be great fun with my wife...and daughter and son....
thanks
OD
Logged
MrbLOB9000
Ace

Posts: 12,896

Join Date: Apr, 2002


« Reply #10 on: July 11, 2007, 12:53:00 AM »

there was a program I saw that was supposed to detect if a cat was walking on your keyboard and disregard those keystrokes, that may be useful as well Smiley
Logged
rrussell
Ace

Posts: 3,306

Join Date: Jul, 2004


« Reply #11 on: July 12, 2007, 06:06:29 PM »

Re: Toddlerkeys...

Note that by default this program (even when not active/taking over your screen) locks your optical drive trays.

I found that out by installing w/out reading the documentation Wink and then getting very very confused when the drive wouldn't open if I clicked the eject button.

Fortunately, I figured it out before replacing the "faulty" drive :cheese:
Logged
Intuit
Ace

Posts: 10,355

Join Date: Oct, 2002


« Reply #12 on: July 12, 2007, 08:13:49 PM »

Back in the good'ol days of '98, a reboot always resolved locked drive issues.

Never-the-less that is interesting though... you'd think it would unlock the drives as apart of the unload routine.
Logged
rrussell
Ace

Posts: 3,306

Join Date: Jul, 2004


« Reply #13 on: July 12, 2007, 10:18:46 PM »

Quote from: "Intuit" date="1184285629"
Back in the good'ol days of '98, a reboot always resolved locked drive issues.

Never-the-less that is interesting though... you'd think it would unlock the drives as apart of the unload routine.

Yeah, that's when I got REALLY curious - a reboot resolved nothing.  I was able to open/close the drive during the boot, but once at desktop, it was locked again.

The issue is that it doesn't really unload, it stays active in the system tray, waiting for you to configure and/or activate it.  And while it's running there, you can tell it to lock the drive trays - it's simply an option that I didn't realize was there at first.  I unchecked that option, and all was well.

I assume it's to protect your pc from kids who like pushing buttons while you're working...
Logged
Intuit
Ace

Posts: 10,355

Join Date: Oct, 2002


« Reply #14 on: July 13, 2007, 01:12:10 PM »

Oh okay... I always remove programs from HKCU/HKLM - Software\Microsoft\Windows\CurrentVersion\Run and then pick&choose as to which ones I stick in the Startup folder of the Explorer shell.  NOBODY[/size] ever uses that folder!  ::grunt::  Everytime I stick notes there and even include the location of the note in the note I always get asked, "okay how do I keep this from showing up everytime I boot?".  ::doublegrunt::  The good thing about moving it the startup folder (besides easy access) is if for any particular reason you wish not to load any startup programs during boot then simply hold the SHIFT key.  Makes troubleshooting boots a sinch provided a program loading as a service isn't causing the issue(s).

EDIT:  I should say "disable" instead of "remove".  When you remove program entries they typically stick themselves back but I found that if you instead, alter the program entries, they remain disabled and you don't have to fight with the program about keeping it out of the boot routine.

For those that are really anal about keeping programs out of the boot routine, you can set read-only permissions (do NOT use DENY permissions) on the RUN registry keys.  Only problem is you won't be able to capture the program's commandline and move it to the startup folder if you do that.
Logged
rrussell
Ace

Posts: 3,306

Join Date: Jul, 2004


« Reply #15 on: July 13, 2007, 01:45:49 PM »

Quote from: "Intuit" date="1184346730"
When you remove program entries they typically stick themselves back but I found that if you instead, alter the program entries, they remain disabled and you don't have to fight with the program about keeping it out of the boot routine.

OMG Quicktime and adobe gave me FITS until I figured out to do that. Great advice!

Have you ever had a program fail to install when it wasn't allowed to add an entry to the Run registry area?
Logged
Intuit
Ace

Posts: 10,355

Join Date: Oct, 2002


« Reply #16 on: July 13, 2007, 02:10:40 PM »

Quote from: "rrussell" date="1184348749"
Have you ever had a program fail to install when it wasn't allowed to add an entry to the Run registry area?
Another potential issue of making the RUN key read-only.  Worse part is they won't tell you why the install failed either.


Largely impractical and slow, I did put together a batch script awhile back that compares the current RUN key to a backup created before.  If they didn't match it would then save the new key to a file, restore the old key, then notify the user of the change while using WinDiff to highlight the added registry entry(ies).  If the user wanted to restore the change they'd simply merge the exported registry script then delete the backup of the old key.  The script would also automatically reboot as a way of unloading the program if the user didn't abort.  I really should try to port the script over to VBS.  With XP Pro it could be launched as a shutdown script as well.  Maybe get around to it one of these years...

EDIT:  Have to keep reminding myself the reason I never bothered so far is precisely because programs keep adding themselves back and the entires instead have to be modified versus removed.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: