Last active
May 10, 2022 19:24
-
-
Save soulhakr/6004821 to your computer and use it in GitHub Desktop.
[List Mapped Network Drives (VBScript)] #windows #wsh #vbscript #utility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'' | |
' 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