Networked drive in purgatory after `net use` start-up script
First check if drive h: was mapped using a different account. When a drive is mapped from a service, it is only available from the system account, and there is also a different running it normally, or using the UAC "Run as administrator" feature. If you want to unmap it, you must do it the same way as it was mapped.
You can check if you can ping the other computer before trying to map a drive.
You can also try to connect to the other computer using an explicit username and password. And if you map it in a login script, there is no need to use the /persistent option.
net use \\anothercomputer /user:username password > c:\temp\netuse.log 2>&1
net use h: \\anothercomputer\d$\somefolder
In the example above I write the output of the first net use command to a logfile, so you can check for errormessages afterwards.
If you use the /persistent option, you should not need to remap it again, you can use
if exist h:\nul ...
to check if drive h: already exists.
Jeff
Interested in .NET, ASP.NET, C#, VB, (X)HTML, CSS, JavaScript, bjj, snowboarding, mountain biking and Jesus.
Updated on June 04, 2022Comments
-
Jeff almost 2 years
I have a BAT file that runs on startup via the group policy on an internal server. The BAT executes a nant script which then maps several external locations via
net use
command. Until now, all mappings have been to external computers that are part of a different domain via public IPs.net use e: \\111.111.111.111\someshare$ /persistent:yes net use f: \\111.111.111.222\someshare$ /persistent:yes net use g: \\111.111.111.333\someshare$ /persistent:yes
This has been successful. Now, I added a new computer that is part of the same network and domain as the internal server. While the old mappings continue to work, the new mapping does not.
net use h: \\anothercomputer\d$\somefolder /persistent:yes
I only know that this doesn't work because subsequent scripts that depend on this drive mapping are all failing, saying that the location doesn't exist. If I try to run the same connection script manually,
net use
saysSystem error 85 has occurred... The local device name is already in use.
Ok, so it mapped already somewhere, somehow. So I try to unmap it using
net use h: /d
and that fails.The network connection could not be found.
So I cannot map it. I cannot unmap it. Apparently it exists in some networking purgatory. What is going on here? How can I get this new location mapped and visible to my scripts?
-
Jeff almost 13 yearsthere was no terminal services involved, and i am using win 2003 sp2 anyway. thanks for answer
-
Jeff almost 13 yearsI already had another means of getting the command output but when I tried this way
> c:\whatever.txt
, i was getting different output. very strange. anyway, the new log was able to help me pinpoint the exact problem (wrong user name and password) and correct my script. thanks! -
Skurfur over 3 yearsThe first point "mapped using a different account - e.g. system account" was key. In admin cmd prompt, I used Sysinternals
psexec -s -i cmd.exe
to become the system account, typednet use
, verified presence of the "hidden" mapped drive, deleted it vianet use
and now a regular user account can map to the drive letter again. Old post, I know, but still relevant. Many thanks @wimh!