none
Script for finding out the UNC paths of a users mapped drives RRS feed

  • Question

  • Hi!

    Hopefully someone here can help me with this. Sorry if this is the incorrect forum! :)

    Using "net use" in CMD gets me all the UNC paths for the mapped drives on my PC - Great! 

    However...

    Do you know of any way to do the same to find out the UNC paths for mapped drives of a network user?

    For example if I wanted to know what the UNC paths are for your mapped drives and were both on the same network, are you aware of a CMD command that will give me that? I've been researching it but I have come up with zip!

    Thanks for your help!

    Wednesday, June 15, 2016 10:24 PM

Answers

  • Here's a short script you can deploy to users' desktops - they can click to run it and it will list drive mappings:


    // mappedDrives.js
    
    var wshNetwork = new ActiveXObject("WScript.Network");
    var networkDrives = wshNetwork.EnumNetworkDrives();
    var results = "";
    for ( var i = 0; i < networkDrives.length; i += 2 ) {
      var resultLine = networkDrives.Item(i) + " -> " + networkDrives.Item(i + 1);
      if ( results != "" ) {
        results += "\r\n" + resultLine;
      }
      else {
        results = resultLine;
      }
    }
    
    var wshShell = new ActiveXObject("WScript.Shell");
    if ( results != "" ) {
      wshShell.Popup(results, 0, "Mapped Drives");
    }
    else {
      wshShell.Popup("No mapped drives detected", 0, "Mapped Drives");
    }
    


    -- Bill Stewart [Bill_Stewart]

    Thursday, June 16, 2016 3:43 PM
    Moderator

All replies

  • You cannot read the session of remote users.  You can find the persisted mappings from the user registry.  Of course you will have to have advanced programming skills to do this.  It is not built into PowerShell or any other scripting language and it cannot be done in shell script (CMD).

    \_(ツ)_/


    • Edited by jrv Wednesday, June 15, 2016 10:47 PM
    Wednesday, June 15, 2016 10:46 PM
  • Why? What problem does this solve?

    -- Bill Stewart [Bill_Stewart]

    Wednesday, June 15, 2016 11:45 PM
    Moderator
  • I work in a service desk which supports a few thousand users. They rarely know what their mapped drives are mapped to. The nature of the business is that they are not by their PC all day. So they would request access to "the S: drive"... and then we have to chase them to find out what that is. Granted we have details of some of the paths but some users just map drives to what they have access to and give it any drive letter that's free. Its not a show stopper. Just seeing if we can save time really.
    Thursday, June 16, 2016 3:38 PM
  • Here's a short script you can deploy to users' desktops - they can click to run it and it will list drive mappings:


    // mappedDrives.js
    
    var wshNetwork = new ActiveXObject("WScript.Network");
    var networkDrives = wshNetwork.EnumNetworkDrives();
    var results = "";
    for ( var i = 0; i < networkDrives.length; i += 2 ) {
      var resultLine = networkDrives.Item(i) + " -> " + networkDrives.Item(i + 1);
      if ( results != "" ) {
        results += "\r\n" + resultLine;
      }
      else {
        results = resultLine;
      }
    }
    
    var wshShell = new ActiveXObject("WScript.Shell");
    if ( results != "" ) {
      wshShell.Popup(results, 0, "Mapped Drives");
    }
    else {
      wshShell.Popup("No mapped drives detected", 0, "Mapped Drives");
    }
    


    -- Bill Stewart [Bill_Stewart]

    Thursday, June 16, 2016 3:43 PM
    Moderator
  • Thank you Bill! Made my day :) 
    Friday, June 17, 2016 9:54 PM