使用网络使用

时间:2016-02-05 13:30:15

标签: windows batch-file net-use

当我尝试使用 Hudson 中配置的批处理文件net use时,我遇到以下问题。

我在远程Windows Server 2012中以管理员身份添加了test用户,并设置了密码。

我的批处理脚本:

net use p: /delete  
net use p: "\\cazrt\C$" /USER:test /PERSISTENT:NO xxxxx
set "source=%~1"
set "target=p:/%~2"

echo "%source%" "%target%"

echo F|xcopy /S /I /Q /Y "%source%" "%target%"

执行时输出:

[exec] C:\HudsonProjects\NGA>net use p: /delete   
[exec] 
[exec] C:\HudsonProjects\apps>net use p: "\\cazrt\C$" /USER:test /PERSISTENT:NO xxxxx 
[exec] System error 5 has occurred.
[exec] 
[exec] Access is denied.

如果我尝试使用net use而没有PERSISTENT,我会收到相同的访问拒绝错误,并且无法找到网络连接。

执行时输出:

[exec] C:\HudsonProjects\NGA>net use p: /delete   
[exec] 
[exec] C:\HudsonProjects\apps>net use p: "\\cazrt\C$" /USER:test xxxxx 
[exec] The network connection could not be found.
[exec] More help is available by typing NET HELPMSG 2250.
[exec] 
[exec] 
[exec] 
[exec] C:\HudsonProjects\apps>set "source=D:/target/DROP" 
[exec] 
[exec] C:\HudsonProjects\apps>set "target=p:/C:/temp" 
[exec] 
[exec] C:\HudsonProjeSystem error 5 has occurred.
[exec] 
[exec] Access is denied.

如果我从本地Windows机器输入net use,它会显示:

\\cazrt\c$ command executed successful.

1 个答案:

答案 0 :(得分:1)

您可以签出https://helgeklein.com/blog/2011/08/access-denied-trying-to-connect-to-administrative-shares-on-windows-7/解决方案

基本上:

无论您是否喜欢,解决方案非常简单。可以通过将注册表值LocalAccountTokenFilterPolicy设置为1来禁用UAC远程限制。

键:HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Policies \ System 值:LocalAccountTokenFilterPolicy 数据:1(禁用,0启用过滤) 类型:REG_DWORD(32位) 重新启动后,不再过滤来自远程连接的访问​​令牌。在Windows 8和Windows 10上,甚至不需要重新启动。