In my MS-Access application (which runs on a Windows 2012R2 server) I need to check which local drives have been shared by my Remote Users in the Remote Desktop Local Devices and Resources tab.
I tried this:
Dim wql As String, SrvEx As Object, WMIObj As Object, WMIObjEx As Object
wql = "Select * From Win32_LogicalDisk"
Set SrvEx = GetObject("winmgmts:root/CIMV2")
Set WMIObj = SrvEx.ExecQuery(wql)
For Each WMIObjEx In WMIObj
Me.Text1 = Me.Text1 & WMIObjEx.Path_.RelPath & vbCrLf
Next
This lists the physical drives on the remote server, not the drives that have been shared.
I tried to change the SQL string to:
wql = "Select * From Win32_MappedLogicalDisk"
This does not produce any results.
It is the host \\tsclient
to search. A remote drive D
will be reached with:
\\tsclient\D
So, the very simple method would be to call Dir
in a loop using the possible drive letters at the client, like:
? Dir("\\tsclient\D\", vbDirectory)
This will return a folder at the client or raise an error if D
is not shared.
Or just to raise an error:
Dir "\\tsclient\D\", vbDirectory