gpt4 book ai didi

batch-file - IF EXIST 对 C :\Windows\System32 in Windows batch (Inno Setup) 中文件的错误行为

转载 作者:行者123 更新时间:2023-12-01 11:28:57 26 4
gpt4 key购买 nike

我正在尝试通过 Inno Setup 使用批处理脚本复制一个 Windows .dll 文件。

显然,即使 C:\Windows\System32 中没有 msvcr120.dll 文件(我可以确认)我也只能看到 “文件存在“。当然,我也尝试去掉下面的双引号。

if exist "C:\Windows\System32\msvcr120.dll" (
rem file exists
echo "file exists"
pause
) else (
rem file doesn't exist
copy %1\Utilities\msvcr120.dll C:\Windows\System32\msvcr120.dll
echo "file doesn't exist"
pause
)

我手动检查过

C:\Users\changwon>dir /A:HS C:\Windows\System32\msvcr120.dll
Volume in drive C has no label.
Volume Serial Number is 4A80-BDED

Directory of C:\Windows\System32

File Not Found

你能告诉我哪里出了问题吗?

如何在 Inno Setup 中运行批处理

[Run]

Filename: "{app}\bin\Icacls\cacls.bat"; Parameters: """{app}"""
Filename: "{app}\Install\psql_init.bat"; Parameters: """{app}"""

其他结果

C:\Users\changwon>dir /A:L C:\Windows\System32\msvcr120.dll
Directory of C:\Windows\System32

File Not Found

C:\Users\changwon>where msvcr120.dll
INFO: Could not find files for the given pattern(s).

更新

Windows 7 64 位,C:\Windows\SysWOW64 中有一个 msvcr120.dll。但我正在尝试将文件从我的源目录复制到 C:\Windows\System32。

最佳答案

该文件可能存在于 C:\Windows\SysWOW64 中。

Inno Setup 是一个 32 位应用程序。所以默认情况下,要运行批处理文件,它会执行 32 位 cmd.exe

32位cmd.exe,查询C:\Windows\System32时,gets redirectedC:\Windows\SysWOW64

了解 issues with 32-bit vs. 64-bit installations .


如果您使用 [Run] 部分中的条目运行批处理文件,请使用 64bit flag强制执行 64 位 cmd.exe:

[Run]
Filename: "{app}\bin\Icacls\cacls.bat"; Parameters: """{app}"""; Flags: 64bit
Filename: "{app}\Install\psql_init.bat"; Parameters: """{app}"""; Flags: 64bit

虽然如果它是一个 32 位 DLL,您实际上需要它在 C:\Windows\SysWOW64 中。

关于batch-file - IF EXIST 对 C :\Windows\System32 in Windows batch (Inno Setup) 中文件的错误行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34878930/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com