强制bat文件使用非默认cmd.exe
我正在编写一个 .bat 文件来自动处理一些脚本生成,这样我就不必每次运行它时都输入六个命令参数。
我必须从批处理文件运行 vb 脚本
@call ..\Database\scripts\runscriptupdates.vbs
但是,只有使用命令提示符时,该脚本才会运行
C:\Windows\SysWOW64\cmd.exe
默认情况下,bat 文件使用 system32 中的 cmd.exe
C:\Windows\System32\cmd.exe
有没有办法强制批处理文件使用此 cmd。 exe来运行vbs文件?我已经在网上搜索了大约一个小时,但还没有找到任何有帮助的东西(到目前为止)。
我尝试使用“start ...”运行 syswow64,但它似乎不接受后面的参数。
非常感谢,尼尔
I'm writing a .bat file to handle some script generation automatically so I don't have to type in half a dozen command arguments each time I want to run it.
I have to run a vb script from the batch file
@call ..\Database\scripts\runscriptupdates.vbs
However the script will only run if using the the command prompt from
C:\Windows\SysWOW64\cmd.exe
By default the bat file uses the cmd.exe in system32
C:\Windows\System32\cmd.exe
Is there a way to force the batch file to use this cmd.exe to run the vbs file? I've been trawling the web for about an hour now and haven't found anything which helps (so far).
I've tried running the syswow64 with "start ..." however it doesn't seem to take the arguments after it.
Many thanks, Neil
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试:
这将从 32 位命令提示符处运行批处理本身。因此,对 vbs 的调用也将来自 32 位命令提示符。
You can try:
This will run the batch itself from a 32-bit command prompt. Thus, the call to your vbs will also be coming from a 32-bit command prompt.
我也遇到了这个问题,我找到了解决的方法
您只需要更改
系统变量
。转至控制面板 » 系统 » 高级系统设置 » 环境变量。
找到变量
ComSpec
,然后只需单击编辑... 并将路径更改为"C:\Windows\SysWow64\cmd.exe"
I also had this problem, and I found the way to solve it.
You just need to change
System Variables
.Go to Control Panel » System » Advanced System Settings » Environment Variables.
Find the variable
ComSpec
, then just click Edit... and change the path to"C:\Windows\SysWow64\cmd.exe"
尝试在批处理文件中输入这一行。
%windir%\SysWoW64\cmd.exe /c ["]cscript [脚本名称] [主机选项] [脚本参数][" ]
其中:
脚本名称是脚本文件的名称,包括文件扩展名和任何必要的路径信息。
主机选项是启用或禁用各种 Windows 脚本宿主功能的命令行开关。主机选项前面始终带有两个斜杠 (//)。
脚本参数是传递给脚本的命令行开关。脚本参数前面始终带有一个斜杠 (/)。
示例:
%windir%\SysWoW64\cmd.exe /c "cscriptVoltageDrop.vbs /"Campbell.sin" "L08""
注意:在这一行中,我没有传递任何主机选项。 字符串
cscriptVoltageDrop.vbs /"Campbell.sin" "L08"作为命令执行。
此命令将在 32 位命令提示符中将
Try typing this one line in your batch file.
%windir%\SysWoW64\cmd.exe /c ["]cscript [script name] [host options] [script arguments]["]
Where:
script name is the name of the script file, including the file name extension and any necessary path information.
host options are the command-line switches that enable or disable various Windows Script Host features. Host options are always preceded by two slashes (//).
script arguments are the command-line switches that are passed to the script. Script arguments are always preceded by one slash (/).
Example:
%windir%\SysWoW64\cmd.exe /c "cscript VoltageDrop.vbs /"Campbell.sin" "L08""
Note: In this line I do not pass any host options. This command will execute the string,
cscript VoltageDrop.vbs /"Campbell.sin" "L08"
as a command in the 32-bit command prompt.