windowsbat文件错误

发布于 2024-11-06 00:49:06 字数 232 浏览 1 评论 0原文

我尝试在网络共享上启动 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 技术交流群。

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

发布评论

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

评论(5

蓝海 2024-11-13 00:49:06

您有机会先安装网络共享吗?

net use \\dev\applets z:
z:\mybatchfile.bat

Do you have a chance to mount the network share first?

net use \\dev\applets z:
z:\mybatchfile.bat
孤凫 2024-11-13 00:49:06

您可以让命令行处理器在批处理脚本启动时自动将 UNC 路径映射到驱动器:

pushd %~dp0
echo %CD%
popd

当 popd 命令执行时,或者当脚本结束时,驱动器将自动取消映射。

唯一的缺点是脚本运行时您仍然会收到错误消息。

You can get the command-line processor to automatically map your UNC path to a drive when the batch script starts:

pushd %~dp0
echo %CD%
popd

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.

各空 2024-11-13 00:49:06

我遇到了同样的问题..虽然脚本运行得很好,但 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.

羁〃客ぐ 2024-11-13 00:49:06

如果您不想使用驱动器映射,可以使用 注册表破解

HKEY_CURRENT_USER
      \Software
         \Microsoft
            \Command Processor

添加值 DisableUNCCheck REG_DWORD 并将该值设置为 0 x 1(十六进制)。

警告:如果启用此功能并启动当前目录为 UNC 名称的控制台,从该控制台启动应用程序,然后关闭控制台,则可能会导致从该控制台启动的应用程序出现问题。

If you want to go without drive-mapping you can use registry hack from Microsoft KB.

HKEY_CURRENT_USER
      \Software
         \Microsoft
            \Command Processor

Add the value DisableUNCCheck REG_DWORD and set the value to 0 x 1 (Hex).

WARNING: If you enable this feature and start a Console that has a current directory of an UNC name, start applications from that Console, and then close the Console, it could cause problems in the applications started from that Console.

把人绕傻吧 2024-11-13 00:49:06

您可以创建映射网络驱动器。假设您使用的是 Windows XP,该过程是:

在 Windows 资源管理器窗口中,

  • 单击工具
  • 单击映射网络驱动器
  • 选择驱动器号和文件夹(例如 X :\\dev\applets
  • 单击完成

您现在只需输入

x:
cd applets

命令提示符并运行批处理文件即可。

或者

您还可以使用NET USE 命令映射网络驱动器。例如,

NET USE X: \\dev\applets
x:

您可以测试 ERRORLEVEL 以查看命令是否成功完成。感谢 这段出色的代码,我可以建议这个解决方案:

@echo off
set alpha=zyxwvutsrqponmlkjihg
SET completed=false

FOR /L %%i in (1,1,23) DO CALL :MAPDRIVE

:MAPDRIVE
    set drive=%alpha:~0,1%
    set alpha=%alpha:~1,23%

    IF NOT %completed%==true (
        ECHO Attempting to mount drive as %drive%
        NET USE %drive%: \\dev\applets
    )

    IF %ERRORLEVEL% EQU 0 SET completed=true


GOTO END

:END

You can create a Mapped Network Drive. Assuming you are on Windows XP, the process is:

In a Windows Explorer window,

  • Click Tools
  • Click Map Network Drive
  • Select a drive letter and a folder (e.g. X: and \\dev\applets)
  • Click Finish

You can now just type

x:
cd applets

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.

NET USE X: \\dev\applets
x:

You can test ERRORLEVEL to see if the command completed successfully. Thanks to this brilliant bit of code, I can suggest this solution:

@echo off
set alpha=zyxwvutsrqponmlkjihg
SET completed=false

FOR /L %%i in (1,1,23) DO CALL :MAPDRIVE

:MAPDRIVE
    set drive=%alpha:~0,1%
    set alpha=%alpha:~1,23%

    IF NOT %completed%==true (
        ECHO Attempting to mount drive as %drive%
        NET USE %drive%: \\dev\applets
    )

    IF %ERRORLEVEL% EQU 0 SET completed=true


GOTO END

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