By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!> Is there a built in function that will determine if a UNC path is mapped,
> and return the drive letter if so?
>
> Sort of the opposite of how @TRUENAME will return the UNC path of a mapped
> drive letter.
>
> Thanks
>
>
>
>
>
Thanks, but I was hoping there might be a purely internal function that does not require running an external command. I already know how to do it that way :) thanks though.
wmiquery /a root\CIMV2 "SELECT * FROM Win32_MappedLogicalDisk WHERE Name = 'G:'"
Caption = G:
Compressed = False
DeviceID = G:
FileSystem = FAT32
FreeSpace = 216183439360
MaximumComponentLength = 255
Name = G:
ProviderName = \\Storage-11c5\PUBLIC\JCaverly_Backup
SessionID = 66992
Size = 499983122432
SupportsDiskQuotas = False
SupportsFileBasedCompression = False
SystemCreationClassName = Win32_ComputerSystem
SystemName = LRDELLXP
VolumeName = PUBLIC
echo %@wmi[root\CIMV2 "SELECT * FROM Win32_MappedLogicalDisk WHERE Name = 'G:'"]
G:
False
G:
FAT32
216183439360
255
G:
\\Storage-11c5\PUBLIC\JCaverly_Backup
66992
499983122432
False
False
Win32_ComputerSystem
LRDELLXP
PUBLIC
echo %@wmi[root\CIMV2 "SELECT * FROM Win32_MappedLogicalDisk WHERE Name = 'I:'"]
I:
False
I:
FAT32
216183439360
255
I:
\\Storage-11c5\PUBLIC\JLC\My Documents\My Music\My MP3s
66992
499983122432
False
False
Win32_ComputerSystem
LRDELLXP
PUBLIC
wmiquery /a root\CIMV2 "SELECT * FROM Win32_MappedLogicalDisk WHERE ProviderName = '\\\\Storage-11c5\\PUBLIC\\JCaverly_Backup'"
Caption = G:
Compressed = False
DeviceID = G:
FileSystem = FAT32
FreeSpace = 216183439360
MaximumComponentLength = 255
Name = G:
ProviderName = \\Storage-11c5\PUBLIC\JCaverly_Backup
SessionID = 66992
Size = 499983122432
SupportsDiskQuotas = False
SupportsFileBasedCompression = False
SystemCreationClassName = Win32_ComputerSystem
SystemName = LRDELLXP
VolumeName = PUBLIC
wmiquery /a root\CIMV2 "SELECT * FROM Win32_MappedLogicalDisk WHERE ProviderName = '\\\\Storage-11c5\\PUBLIC\\JLC\\My Documents\\My Music\\My MP3s'"
Caption = I:
Compressed = False
DeviceID = I:
FileSystem = FAT32
FreeSpace = 216183439360
MaximumComponentLength = 255
Name = I:
ProviderName = \\Storage-11c5\PUBLIC\JLC\My Documents\My Music\My MP3s
SessionID = 66992
Size = 499983122432
SupportsDiskQuotas = False
SupportsFileBasedCompression = False
SystemCreationClassName = Win32_ComputerSystem
SystemName = LRDELLXP
VolumeName = PUBLIC
wmiquery /a root\CIMV2 "SELECT ProviderName FROM
Win32_MappedLogicalDisk WHERE Name = 'K:'"
\\lucky\e$
wmiquery /a root\CIMV2 "SELECT Name FROM Win32_MappedLogicalDisk WHERE
ProviderName = '\\\\lucky\\e$'"
K:
FUNCTION ISPATHMAPPED `%@execstr[wmiquery /a root\CIMV2 "SELECT
Name FROM Win32_MappedLogicalDisk WHERE ProviderName = '%1'"]`
echo %@ispathmapped[\\\\lucky\\e$]
K:
This is because ProviderName is not a key.Note the (apparently necessary) doubling of
backslashes.
> On Wed, 21 Jul 2010 21:23:56 -0400, Joe Caverly
> <> wrote:
>
> |I have drive I: and drive G: mapped on my system. Using WMI I found
> the following;
>
> Nice one, Joe.
>
> You can make the output terser and do a backwards lookup (which is
> what the OP wants to do). Note the (apparently necessary) doubling of
> backslashes.
>
>
> Code:
> ---------
> wmiquery /a root\CIMV2 "SELECT ProviderName FROM
> Win32_MappedLogicalDisk WHERE Name = 'K:'"
> \\lucky\e$
>
> wmiquery /a root\CIMV2 "SELECT Name FROM Win32_MappedLogicalDisk WHERE
> ProviderName = '\\\\lucky\\e$'"
> K:
> ---------
> This suggests:
>
>
> Code:
> ---------
> FUNCTION ISPATHMAPPED `%@execstr[wmiquery /a root\CIMV2 "SELECT
> Name FROM Win32_MappedLogicalDisk WHERE ProviderName = '%1'"]`
>
> echo %@ispathmapped[\\\\lucky\\e$]
>
> K:
> ---------
>
>
>