简体   繁体   English

VBScript正在从VBScript的文件路径而不是批处理路径运行批处理文件

[英]VBScript is running batch file from the file path of VBScript, not path of batch

I am having a problem with a VBScript which was working just fine yesterday, but for some reason does not work today. 我有一个VBScript的问题,该昨天昨天工作正常,但由于某种原因今天不工作。 I am attempting to run a batch file off the sever, from a VBScript in an adjacent server folder. 我正在尝试从相邻服务器文件夹中的VBScript运行服务器上的批处理文件。 The VBScript reads like this: VBScript的内容如下:

Dim Shell
Set Shell = CreateObject ("WScript.Shell")
Shell.run "cmd /K ..\Analyses\GeniE_SP.bat"

The VBScript is in a file in the folder ..\\Local Design Calculations, whereas the batch file is in ..\\Analyses. VBScript位于.. \\ Local Design Calculations文件夹中的文件中,而批处理文件位于.. \\ Analyses中。 The script is calling up the batch file just fine, but when the batch file runs it is running with the file path of the VBScript. 该脚本可以很好地调用该批处理文件,但是当该批处理文件运行时,它将使用VBScript的文件路径运行。 This is what is shown in the command window: 这是命令窗口中显示的内容:

I:\Shared\Projects\105874\Local Design Calculations>REM @echo off

If I simply run the batch file from its actual location, there are no problems as the first line in the command window will read like this (as it should): 如果仅从实际位置运行批处理文件,就不会有问题,因为命令窗口中的第一行将显示为(应如此):

I:\Shared\Projects\105874\Analyses>REM @echo off

Any ideas? 有任何想法吗?

Shell.run "cmd /K cd ..\Analyses & GeniE_SP.bat"

如果需要批处理文件的当前活动目录,请首先进行更改。

You would specify the full path to what you want. 您将指定所需路径的完整路径。 There in no such thing as per drive default directories in WinNT. WinNT中没有每个驱动器默认目录。 Graphical programs (ie normal) set their own default directory based on the folder the exe is in (and that's not a per drive default but a program default). 图形程序(即普通程序)根据exe所在的文件夹设置自己的默认目录(这不是每个驱动器的默认值,而是程序的默认值)。

For console programs (ie non graphical) cmd.exe simulates per drive default directories. 对于控制台程序(即非图形),cmd.exe模拟每个驱动器的默认目录。

SPECIFY FULL PATHS. 指定完整路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM