从Inno Setup调用.bat文件时,无法识别.bat文件中的命令,但是当我手动运行bat文件时,该命令可以正常工作 [英] A command in a .bat file is unrecognized when the .bat file is called from an Inno Setup but works fine when I run the bat file manually
问题描述
我有以下.bat文件:
I have the following .bat file:
fbwfmgr /enable
.
.
.
fbwfmgr /addexclusion c: "some folder 1"
fbwfmgr /addexclusion c: "some folder 2"
.
.
.
我在Inno设置的[Run]
部分中调用的
如下:
which I'm calling from the [Run]
section in my Inno Setup like this:
Filename: "{tmp}\set_write_protection_rules.bat";
我也尝试过这个:
Filename: "{cmd}"; Parameters: "/c ""{tmp}\set_write_protection_rules.bat""";
我总是收到消息
'fbwfmgr'无法识别为内部或外部命令,可操作程序或批处理文件.
'fbwfmgr' is not recognized as an internal or external command, operable program or batch file.
如果我通过双击运行.bat文件,则该文件有效;如果我自己从cmd窗口运行该文件,则该文件有效.我在这里想念什么?
If I run the .bat file by double clicking on it it works, if I run it from a cmd window myself it works. What am I missing here?
我正在以管理员身份登录的Windows Embedded Standard x64系统上运行此程序.
I'm running this on a Windows Embedded Standard x64 system logged in as the administrator.
将完整路径添加到fbwfmgr.exe
并不能解决问题(我也手动查看过这是fbwfmgr.exe
的实际位置):
Adding the full path to the fbwfmgr.exe
does not solve the issue (I have also manually looked that that's the actual location of fbwfmgr.exe
):
%systemroot%\system32\fbwfmgr.exe /enable
I found a similar thread here where the OP is having the same problem while running the .bat file from vbs, no solution seems to have been found there. From a suggestion there to cut the middle man I've tried calling fbwfmgr
directly from Inno Setup with the following line:
Filename: "{cmd}"; Parameters: "c/ ""fbwfmgr /enable""";
但没有用.它只是打开一个空的控制台窗口.当我尝试从那里呼叫fbwfmgr
时,无法识别它.
but to no use. It just opens an empty console window. When I try to call fbwfmgr
from there, it is not recognized.
推荐答案
不是吗,因为系统上C:\Windows\System32
中只有fbwfmgr
的64位版本?
Isn't it, because there's only 64-bit version of the fbwfmgr
in the C:\Windows\System32
on the system?
As Inno Setup in a 32-bit application, it by default gets redirected to C:\Windows\SysWOW64
(32-bit version of C:\Windows\System32
). If there's no 32-bit version of fbwfmgr
in the C:\Windows\SysWOW64
, Inno Setup cannot find it.
添加 Flags: 64bit
进行Inno设置找到fbwfmgr
的64位版本.
此外,通过命令解释器(cmd.exe
)运行.exe
应用程序也没有意义.
Also, there's no point running a .exe
application via a command interpreter (cmd.exe
).
[Run]
Filename: "fbwfmgr.exe"; Parameters: "/enable"; Flags: 64bit
使用批处理文件,机制更加复杂.默认情况下,Inno Setup(属于32位应用程序)运行32位cmd.exe
,而该cmd.exe
依次进入C:\Windows\SysWOW64
.如果添加Flags: 64bit
,Inno Setup将运行64位的cmd.exe
,它将查看C:\Windows\System32
.
With a batch file, the mechanics is bit more complicated. Inno Setup by default (being a 32-bit applications) runs a 32-bit cmd.exe
, which in turns looks into the C:\Windows\SysWOW64
. If you add the Flags: 64bit
, Inno Setup will run a 64-bit cmd.exe
, which will look into the C:\Windows\System32
.
[Run]
Filename: "{tmp}\set_write_protection_rules.bat"; Flags: 64bit
或使用 64位安装模式.
有关类似问题,请参见从Inno Setup执行的PowerShell脚本因检索组件的COM类工厂"而失败. CLSID为{XXXX}的用户失败-错误80040154". .
这篇关于从Inno Setup调用.bat文件时,无法识别.bat文件中的命令,但是当我手动运行bat文件时,该命令可以正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!