本文介绍了调用共享上的批处理对本地驱动器的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:我有两个服务器ServerA和ServerB。 ServerA存储我的批处理脚本并管理我的任务计划程序以进行自动化。 ServerB存储了几个必须添加到ServerA上的任务计划程序的.cmd和.bat文件。

Environment: I have two servers, ServerA and ServerB. ServerA stores my batch scripts and manages my Task Scheduler for automation. ServerB stores several .cmd and .bat files that must be added to the Task Scheduler on ServerA.

问题: ServerB的.cmd文件具有本地驱动器引用,如下所示。当从ServerA的命令行调用时,它们返回错误,因为命令行在ServerA而不是在ServerB中查找它们。我无法更改这些引用,因为它们有大量的依赖项。

Issue: ServerB's .cmd files have local drive references as you'll see below. When called from ServerA's command line, they return errors because the command line is looking for them in ServerA instead of in ServerB. I cannot change these references because they have a considerable number of dependent pieces.

代码:

BatchA.bat:

pushd \\ServerB\d$
call Folder1\Folder2\Folder3\CommandB.cmd
popd

CommandB.cmd:

call D:\Folder1\Folder2\Folder3\batch1.bat
call D:\Folder1\Folder2\Folder3\batch2.bat
call D:\Folder1\Folder2\Folder3\batch3.bat
call D:\Folder1\Folder2\Folder3\batch4.bat

问题: / strong>如何更新BatchA.bat以从ServerB正确调用CommandB.cmd?

Question: How do I update BatchA.bat to properly call CommandB.cmd from ServerB?

推荐答案

在ServerB上的本地驱动器到ServerA在相同的驱动器号下的方式,当CommandB.cmd从ServerA调用它将有它需要的驱动器,你不需要改变太多。

What you could do is map the local drive on ServerB to ServerA under the same drive letter that way when CommandB.cmd is called from ServerA it will have the drive it need and you wont need to change much.

简而言之,您需要将\ServerB \d $映射到ServerA上的驱动器盘符D:\。

In short you need to map \ServerB\d$ to drive letter D:\ on ServerA.

这篇关于调用共享上的批处理对本地驱动器的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 06:24