Old 12th January 2011, 15:34   #1
Iossoi
Junior Member
 
Join Date: Jan 2011
Posts: 2
Problem With IfFileExists on 64bit Windows

I recently wrote script were I have to check existence of certain driver in users system. I did it by checking if driver file was in Windows\System32\drivers folder with IfFileExists command. I noticed that in 32bit Windows this method worked, but in 64bit Windows IfFileExist does not seems to see *.sys files in Windows\System32\drivers. If I use IfFileExist on some other files in other path it seems to work as it should in 64bit Windows.

I wrote this little script to demonstrate problem. It looks beep.sys that should (hopefully) exist on every Windows machine.

code:

Name "beepexist"
OutFile "beepexist.exe"

SetDateSave on
SetDatablockOptimize on
CRCCheck on
SilentInstall normal
XPStyle on

Function .onInit

IfFileExists $SYSDIR\drivers\beep.sys 0 notfound

MessageBox MB_OK "beep.sys found at: $SYSDIR\drivers\"
Goto end

notfound:

MessageBox MB_OK "No beep.sys found at: $SYSDIR\drivers\"

end:

FunctionEnd

Section "-boo"
;
SectionEnd



I first thought that $SYSDIR could give wrong path to C:\Windows\SysWOW64\drivers but path seems to correct and hardcoding path in script give same results. Why IfFileExists shows such behaviour on 64bit Windows ? Or have I understood something wrong?

Best regards
Iossoi is offline   Reply With Quote
Old 12th January 2011, 20:26   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,333
Disable file system redirection with the macros in x64.nsh, then $sysdir will be correct. Or use the half documented $windir\sysnative hack on 64 bit OS

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th January 2011, 15:24   #3
Iossoi
Junior Member
 
Join Date: Jan 2011
Posts: 2
Thank you for your answer. I did not understood that redirection happens even when I hardcode path to like this:

code:

IfFileExists C:\Windows\System32\drivers\beep.sys 0 notfound



Instead of using $SYSDIR.
Iossoi is offline   Reply With Quote
Old 13th January 2011, 16:47   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Redirection is done by the OS not NSIS.

Stu
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump