3

I'm trying to copy one Windows .dll file by using a batch script through Inno Setup.

Apparently, even though there is no msvcr120.dll file in C:\Windows\System32 (I can confirm) I can only see "file exists". Of course, I also tried to remove double quotation below.

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
)   

I checked it manually

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

Can you tell me what is wrong?

How to run a batch in Inno Setup

[Run]

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

Other results

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).

UPDATE

Windows 7 64bit and there is a msvcr120.dll in C:\Windows\SysWOW64 instead. But I'm trying to copy the file from my source dir to C:\Windows\System32.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Sigularity
  • 917
  • 2
  • 12
  • 28
  • Perhaps `msvcr120.dll` is hidden? try `dir /A:HS C:\Windows\System32\msvcr120.dll`; or there is a directory with that name -- replace `/A:HS` by `/A:D` to test... – aschipfl Jan 19 '16 at 14:20
  • Updated question. I don't see the file. Actually, there was the file but for my testing, I renamed the original msvcr120.dll to msvcr120_backup.dll. My purpose is to copy the file if it doesn't exist. – Sigularity Jan 19 '16 at 14:24
  • Maybe also try with `dir /A:L C:\Windows\System32\msvcr120.dll` or `dir /S C:\Windows\msvcr120.*`; or type `where msvcr120.dll`... – aschipfl Jan 19 '16 at 14:40
  • 1
    OK, so the problem is as I described in my answer. Did you try the `64bit` flag? – Martin Prikryl Jan 19 '16 at 14:52
  • Hold on second, genius. I'm testing with your advice... – Sigularity Jan 19 '16 at 14:53

1 Answers1

5

The file probably exists in the C:\Windows\SysWOW64.

Inno Setup is a 32-bit application. So by default, to run a batch file, it executes the 32-bit cmd.exe.

The 32-bit cmd.exe, when querying the C:\Windows\System32, gets redirected to the C:\Windows\SysWOW64.

Read about issues with 32-bit vs. 64-bit installations.


If you are running the batch file using an entry in the [Run] section, use the 64bit flag to force execution of the 64-bit cmd.exe:

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

Though if it is a 32-bit DLL, you actually want it in the C:\Windows\SysWOW64.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 1
    PERFECT!!!! Yes, you're right. It was redirected. I need to copy 64bit version of the file. Now, my batch file detects that it doesn't exist and succeeded to copy!! Thank you so much!! – Sigularity Jan 19 '16 at 14:54