1

I have a Script that I am using to try to modify the Drive Mappings on my system. It performs both NET USE [Drive Letter] [Share Path] and NET USE [Drive Letter] /delete, and both of those operations complete successfully (as confirmed by NET USE on its own), but when I open File Explorer, any Mappings that I changed, added or deleted through there are not displayed, and I can even still access the Shared Folders through those Mappings.

For Example:

  • I create a Mapping (B:) to \\127.0.0.1\ShareA, which I can access by going to B:
  • I then run NET USE and I get a list, with one entry, saying Status: OK, Local: B, Remote \\127.0.0.1\ShareA...
  • I then run NET USE B: \\127.0.0.1\ShareB, which a readout stating the operation completed successfully
  • I re-run NET USE, and the single entry has had its Remote value changed to \\127.0.0.1\ShareB
  • I open Explorer (or Run) and go to B:, and I get ShareA, not ShareB

I have done the same with /delete, first time being successfully completed, the next throwing error 2250 (doesn't exist), but the Mapping is still there in File Explorer.

What is occurring that prevents these changes from being propagated to Explorer?

P.S. I am running CMD as an Administrator, I have also tried Restarting the Windows Explorer process (for Folders and Shell, I have the two separate), but neither has made a difference. I am about to try a restart, but that is not a valid solution as these changes need to be made while the system is up.

P.P.S. I have just tried NET USE \\127.0.0.1\ShareA /delete, but I get the same 2250 error

2

1 Answer 1

2

Found out the problem. It was because CMD was running as an Administrator. In a desperate bid to fix it, tried running CMD normally, and those changes are now being applied. Even though it seems counter-intuitive, it appears that when its running as an Admin, USE is operating in a different context.

I don't know what that means in terms of UAC, but I have seen scripts where the Console can have its security permissions elevated while its running. Perhaps if anyone else has this issue, they might be able to see if that works.

2
  • 2
    This is expected behavior. When you run as Administrator, that program is run in a different environment. A different profile if you will. For that same reason, if you run as administrator to an installer that you want to install to a network share, you won't find any shares, because its not your own user. So if you open a cmd prompt as administrator and perform the net use there, the installer will see the network shares.
    – LPChip
    Dec 10, 2014 at 16:15
  • @LPChip Cheers for that clarification bud! Very helpful! I would have though that being an Admin would be Administrative Permissions from the Calling User as opposed to a separate Account, but ah well
    – topherg
    Dec 10, 2014 at 16:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .