'
Aaii, the best way ?? I have no idea, I know at least three totally different ways, I leave "best" up you to..
Personally I like this way a lot, you won't be able to run the code as is, but if your skills are adequate, you should get the idea:
Code: Select all
:§Drive.mounted ()
::
:: last updated : 20/11/2011
:: language dependent : no
:: languages : N/A
::
::OUTPUT:
:: $drives.mounted,[.FLP¦.HD¦.CD¦.NET¦.RMV], $drives.unmounted
::
:: NFO ( uses registry to get mounted drive types
::
:: G . E . N . E . R . I . C . _ . F . L . O . P . P . Y . _ . D . R . I . V . E Floppy
:: 470045004e0045005200490043005f0046004c004f005000500059005f00440052004900560045
:: C . d . R . o . m CD
:: 4300640052006f006d
::
:: 5C003F00 HD
::
:: Networked drives are NOT listed under HKLM\SYSTEM\MountedDevices !
:: )
Code: Select all
for /f "skip=16 tokens=1 delims=\ " %%? in ('mountVol.EXE') do
Code: Select all
for /f "tokens=2,4 delims=\ " %%a in ('reg query HKLM\SYSTEM\MountedDevices') do
Code: Select all
:: $drives.mounted.NET
:: (
for /f "skip=6 tokens=1,2" %%a in (
'net use'
) do if /i ["%%~a"] equ ["OK"] (
::
set "$drives.mounted=!$drives.mounted!, %%~b"
set "$drives.mounted.NET=!$drives.mounted.NET!, %%~b"
set "$drives.mounted.RMV=!$drives.mounted.RMV!, %%~b"
%@echo_% %%~b
)
:: )
I know, it's incomplete, but I really don't want to hijack this wonderful forum.
http://www.dostips.com/forum/viewtopic.php?f=3&t=1893Demounting is done with
mountvol or
net use /delete for networked drives.
Also, is it possible via a batch to unmount a volume on a multivolume disk without removing its drive letter
I think you are confused, mounting means assigning a drive letter, if none assigned it is unmounted
