CMD-IF命令
这个代码怎么了?启动时,它在嵌入第二个连接之前停止CMD-IF命令,cmd,Cmd,这个代码怎么了?启动时,它在嵌入第二个连接之前停止 echo off if exist \\fistcloud\Data-Private goto Connect if exist \\secondcloud\Data-Work goto Connect2 goto Ende :Connect net use D: \\192.168.1.102\Data-Private /user:user password /persistent:no goto Ende :Connect2 net
echo off
if exist \\fistcloud\Data-Private goto Connect
if exist \\secondcloud\Data-Work goto Connect2
goto Ende
:Connect
net use D: \\192.168.1.102\Data-Private /user:user password /persistent:no
goto Ende
:Connect2
net use D: \\192.168.0.2\Data-Work /user:user password /persistent:no
goto Ende
:Ende
exit
goto Ende结束了脚本
使用以下内容:
echo off
if exist \\fistcloud\Data-Private goto Connect
:next
if exist \\secondcloud\Data-Work goto Connect2
goto Ende
:Connect
net use D: \\192.168.1.102\Data-Private /user:user password /persistent:no
goto next
:Connect2
net use D: \\192.168.0.2\Data-Work /user:user password /persistent:no
goto Ende
:Ende
exit
这应该映射可用的
@echo off
if exist \\fistcloud\Data-Private net use D: \\192.168.1.102\Data-Private /user:user password /persistent:no
if exist \\secondcloud\Data-Work net use D: \\192.168.0.2\Data-Work /user:user password /persistent:no
他的代码有什么问题?它在我的电脑上工作。它只能连接一两个,但不能同时连接两个。所以他的代码没有问题。我以为那就是他想要的。他应该提到没有语法问题,只有这个,但我不得不想问题出在哪里:实际上,我有两个nas同步在一起。一个站在家里,另一个在我的办公室。如果我在家登录,我想与站在家中的nas连接。如果我在办公网络中,我想与办公nas连接…下次一定要提到你的目标。(你希望两人都有联系)我们不应该猜到。对不起,你是对的。我有两个nas正在同步。一个站在家里,另一个在我的办公室。如果我在家用电脑登录,我想在家里自动启动nas连接。如果我在办公室网络中,我想连接办公室,那么一次只能访问其中一个吗?实际上,我必须使用相同的驱动器号。它应该连接到我家里的nas或我办公室里的nas…试试上面的方法-在任何地方只有一个会成功。
@echo off
if exist \\fistcloud\Data-Private net use D: \\192.168.1.102\Data-Private /user:user password /persistent:no
if exist \\secondcloud\Data-Work net use D: \\192.168.0.2\Data-Work /user:user password /persistent:no