“net use”启动脚本后网络驱动器处于炼狱状态

发布于 2024-11-06 04:33:39 字数 815 浏览 5 评论 0原文

我有一个 BAT 文件,该文件在启动时通过内部服务器上的组策略运行。 BAT 执行一个 nant 脚本,然后通过 net use 命令映射多个外部位置。到目前为止,所有映射都是通过公共 IP 映射到属于不同域的外部计算机。

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

这已经成功了。现在,我添加了一台新计算机,它与内部服务器属于同一网络和域。虽然旧映射继续有效,但新映射却不起作用。

net use h: \\anothercomputer\d$\somefolder /persistent:yes

我只知道这不起作用,因为依赖于此驱动器映射的后续脚本都失败,并表示该位置不存在。如果我尝试手动运行相同的连接脚本,net use 会说

发生系统错误 85...本地设备名称已被使用。

好的,所以它已经以某种方式映射到某个地方了。因此,我尝试使用 net use h: /d 取消映射它,但失败了。

找不到网络连接。

所以我无法映射它。我无法取消它的映射。显然它存在于某些网络炼狱中。这是怎么回事?如何映射这个新位置并使其对我的脚本可见?

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 says

System 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

陪你搞怪i 2024-11-13 04:33:39

首先检查驱动器 h: 是否已使用不同的帐户进行映射。当驱动器从服务映射时,它只能从系统帐户使用,并且还有一种不同的方式正常运行它,或者使用UAC“以管理员身份运行”功能。如果要取消映射,则必须按照映射时相同的方式进行操作。

在尝试映射驱动器之前,您可以检查是否可以 ping 通另一台计算机。

您还可以尝试使用明确的用户名和密码连接到另一台计算机。如果将其映射到登录脚本中,则无需使用 /persistent 选项。

net use \\anothercomputer /user:username password > c:\temp\netuse.log 2>&1
net use h: \\anothercomputer\d$\somefolder 

在上面的示例中,我将第一个 net use 命令的输出写入日志文件,以便您随后检查错误消息。

如果您使用 /persistent 选项,则不需要再次重新映射它,您可以使用它

if exist h:\nul ...

来检查驱动器 h: 是否已存在。

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.

不回头走下去 2024-11-13 04:33:39

Microsoft 已证明这是以下系统中普遍存在的问题:

Microsoft Windows 2000 Server

Microsoft Windows 2000 Advanced Server

Microsoft Windows 2000 Professional Edition

如果您的内部服务器正在运行其中任何一个,那么下面的链接肯定会对您有所帮助。
即使在其他方面,检查解决方案也没有坏处。另请查看链接 http://support 中页面底部的 Windows 注册表更改部分

。 microsoft.com/kb/308337#top

Microsoft has documented that this is a problem prevalent in following systems:

Microsoft Windows 2000 Server

Microsoft Windows 2000 Advanced Server

Microsoft Windows 2000 Professional Edition

If your internal server is running any of these then this link below will definitely help you.
Even other wise it does not harm to check out the solution. Also Check out the windows registry changes section at the bottom of the page in the link

http://support.microsoft.com/kb/308337#top

橘和柠 2024-11-13 04:33:39

可能是客户端问题。

以下 MS 支持文章指出了具有所描述症状的问题。

解决方法是更改​​尝试映射驱动器的客户端中的注册表值。

https://support.microsoft.com/en-us/kb/253821

Might be a client issue.

The following MS support article identifies a problem that has the described symptoms.

Resolution is to change a registry value in the client that is attempting to map the drive.

https://support.microsoft.com/en-us/kb/253821

您的好友蓝忘机已上羡 2024-11-13 04:33:39

如果系统帐户占用了它,则这是一种更具编程性的方式。不需要 psexec。

在 PowerShell 管理提示中:

New-PSDrive HKU Registry HKEY_USERS
Remove-Item "HKU:\.DEFAULT\Network\H"

重新启动计算机(不幸的是)。

A more programatic way if the system account is hogging it. No psexec needed.

In PowerShell admin prompt:

New-PSDrive HKU Registry HKEY_USERS
Remove-Item "HKU:\.DEFAULT\Network\H"

Restart the computer (unfortunately).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文