Skip to content

Instantly share code, notes, and snippets.

@soulhakr
Last active May 10, 2022 19:24
Show Gist options
  • Save soulhakr/6004821 to your computer and use it in GitHub Desktop.
Save soulhakr/6004821 to your computer and use it in GitHub Desktop.
[List Mapped Network Drives (VBScript)] #windows #wsh #vbscript #utility
''
' List Mapped Network Drives
' Copyright 2022 David Edwards <[email protected]>
''
On Error Resume Next
Const strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_MappedLogicalDisk")
Set strDrives = CreateObject("System.Text.StringBuilder")
strDrives.Append_3 vbNewLine
For Each objItem in colItems
strDrives.Append_3 "Drive Letter: '" & objItem.DeviceID & "' Path: '" & objItem.ProviderName & "'" & vbNewLine
Next
WScript.Echo strDrives.ToString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment