windowsbat文件错误
我尝试在网络共享上启动 BAT 文件,但收到此错误:
'\\dev\applets'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
有解决方法吗?
谢谢!
i try to launch a BAT file on a network share but i get this error:
'\\dev\applets'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
is there a workaround for this?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您有机会先安装网络共享吗?
Do you have a chance to mount the network share first?
您可以让命令行处理器在批处理脚本启动时自动将 UNC 路径映射到驱动器:
当 popd 命令执行时,或者当脚本结束时,驱动器将自动取消映射。
唯一的缺点是脚本运行时您仍然会收到错误消息。
You can get the command-line processor to automatically map your UNC path to a drive when the batch script starts:
When the popd command executes, or when your script ends, the drive will be automatically unmapped.
The only downside to this is that you still get the error message when the script runs.
我遇到了同样的问题..虽然脚本运行得很好,但 CMD.EXE 标头很烦人。
为了隐藏该文本,我只需调用 CLS 作为脚本的第一行。
这将删除那个令人讨厌的 CMD.EXE 标头并显示您想要的任何内容。
希望这有帮助。
I had the same problem.. while the script runs just fine, the CMD.EXE header was annoying.
To supress that text, I simply call a CLS as a first line of my script.
This will remove that nasty CMD.EXE header and display whatever you want afterwards.
Hope this helps.
如果您不想使用驱动器映射,可以使用 注册表破解。
添加值
DisableUNCCheck
REG_DWORD
并将该值设置为0 x 1
(十六进制)。If you want to go without drive-mapping you can use registry hack from Microsoft KB.
Add the value
DisableUNCCheck
REG_DWORD
and set the value to0 x 1
(Hex).您可以创建映射网络驱动器。假设您使用的是 Windows XP,该过程是:
在 Windows 资源管理器窗口中,
工具
映射网络驱动器
X :
和\\dev\applets
)完成
您现在只需输入
命令提示符并运行批处理文件即可。
或者
您还可以使用NET USE 命令映射网络驱动器。例如,
您可以测试 ERRORLEVEL 以查看命令是否成功完成。感谢 这段出色的代码,我可以建议这个解决方案:
You can create a Mapped Network Drive. Assuming you are on Windows XP, the process is:
In a Windows Explorer window,
Tools
Map Network Drive
X:
and\\dev\applets
)Finish
You can now just type
in your command prompt and run your batch file.
ALTERNATIVELY
You can also use the NET USE command to map the network drive. e.g.
You can test ERRORLEVEL to see if the command completed successfully. Thanks to this brilliant bit of code, I can suggest this solution: