2017-02-08 72 views
0

IfFileExists $ WINDIR \ SYSTEM32 \ DRIVERS \ pcitdrv.sys file_found FILE_NOT_FOUND
file_found:
的MessageBox MB_OK的FileFound
FILE_NOT_FOUND:
的MessageBox MB_OK FileNotFoundNSIS脚本无法找到WINDIR文件夹中的文件

即使该文件存在于相应的路径中,该代码仍会执行代码的file_not_found部分。

还试图以下方式:

功能AB
VAR/GLOBAL OnlineOrOffline
$ {找到} “$ WINDIR \ System32 \ drivers下\” “/ L = F /M=pcitdrv.sys”“ SetOnlineOfflineVarliable”
的MessageBox MB_OK $ OnlineOrOffline
FunctionEnd

功能SetOnlineOfflineVarliable
STRCPY $ R0 $ R9
STRCPY $ OnlineOrOffline “发现”
STRCPY $ 0 StopLocate
推$ 0
FunctionEnd

在这种情况下也回调函数没有被调用。

需要关于此的帮助。

或者干脆

我的要求是想用$ WINDIR一个PC/SYSTEM32 /司机/ pcitdrv.sys文件现在和其他PC是不是有这个文件。在安装过程中,会检查一些许可证。我们可以跳过基于文件存在的许可证检查吗?

+0

这是只发生在64位的Windows? – Anders

回答

0

当在64位版本的Windows上运行32位应用程序时,文件系统的某些部分是redirected

$ windir \ system32被重定向到$ windir \ SysWOW64。

!include x64.nsh 
Section 

${DisableX64FSRedirection} 
StrCpy $0 "" 
IfFileExists "$windir\system32\drivers\pcitdrv.sys" 0 +2 
StrCpy $0 "1" 
${EnableX64FSRedirection} 

StrCmp $0 "" 0 file_found 
MessageBox MB_OK FileNotFound 
goto done 
file_found: 
MessageBox MB_OK FileFound 
done: 

SectionEnd 

如果你不关心的Windows XP 64位support您可以使用始终访问“真正的” SYSTEM32一个特殊的伪文件夹:

进行检查时,可以关闭重定向文件夹:

Section 

IfFileExists "$windir\system32\drivers\pcitdrv.sys" file_found ; Check on 32-bit Windows 
IfFileExists "$windir\sysnative\drivers\pcitdrv.sys" file_found ; Check on 64-bit Windows 

MessageBox MB_OK FileNotFound 
goto done 
file_found: 
MessageBox MB_OK FileFound 
done: 

SectionEnd 
+0

谢谢。它的工作原理,但到底是什么0 +2做。也会为所有位版本也是这个脚本的工作?像32/64也 –

+0

0是没有跳跃,+2是跳过这个和下一条指令。应该到处工作。 – Anders

+0

哦!谢谢安德斯。 –

0

还有一个疑问,其实是
$ {} DisableX64FSRedirection
STRCPY $ 0 “”
IfFileExists “$ WINDIR \ SYSTEM32 \ DRIVERS \ pcitdrv.sys” 0 +2
STRCPY $ 0 “1”
$ {EnableX64FSRedirection}
STRCMP $ 0 “” 0 file_found
$ {DisableX64FSRedirection}
STRCPY $ 0 “”
IfFileExists“$ windir \ system32 \ drivers \ tcitdrv。SYS” 0 +2
STRCPY $ 0 “1”
$ {EnableX64FSRedirection}
STRCMP $ 0 “” 0 file_found
转到做
file_found:

完成:
我想检查两个文件PCIT和TCIT。
这是正确的吗?