Search code examples
vb.netdictionarywindowcallpowershell-cmdlet

how to open the windows explorer map network


Windows Explorer - Map Network Drive

Hi All,

I need to be able to open the [Windows Explorer - Map Network Drive] popup using either VB or cmdlet. I tried using the code in both VB and cmdlet:

System.Diagnostics.Process.Start("rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL Connect")

But it does not work.

Any help is appreciated. Thank you.


Solution

  • A little bit of library magic:

    Private Declare Function WNetConnectionDialog Lib "mpr.dll" (ByVal hwnd As Long, ByVal dwType As Long) As Long
    
    Dim ret As Integer = WNetConnectionDialog(Me.hwnd, 1)    'ret is 0 on success