legend Posted November 8, 2017 Posted November 8, 2017 if FileExists("C:\Windows\System32\dsac.exe") Then MsgBox("","","the file exists! and we are happy :)") Else MsgBox("","","please download microsoft remote administration tools",3) ShellExecute("https://www.microsoft.com/en-us/download/details.aspx?id=45520") EndIf I have this weird issue that I can't check if this file exist: dsac.exe. I will tell the file does not exist, even if it does: If i check if notepad.exe exist, or if mspaint.exe exist, witch is also in system32, then it works fine, it will say that it exist, I tried to check the rights on dsac.exe, it's exactly the same as on notepad.exe
RTFC Posted November 8, 2017 Posted November 8, 2017 (edited) If you're running under 64-bit Windows, look up SysWow64; and then I would suggest you use macro @SystemDir instead of hard-coding the path. Edited November 8, 2017 by RTFC My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O
jguinch Posted November 8, 2017 Posted November 8, 2017 @SystemDir stores the 32 bits path with a script running in 32 bits. In a x64 Windows, a 32 bits application maps the system32 directory to c:\windows\syswow64 (it's the WOW6432 redirection). So when the application accesses to c:\windows\system32, it accesses to the c:\windows\syswow64 folder. You can enable or disable the WOW6432 redirection using _WinAPI_Wow64EnableWow64FsRedirection(True/False). But don't use @SystemDir, because it always returns the Syswow64 path (with a 32 bits running script). You can use _WinAPI_ShellGetKnownFolderPath($FOLDERID_System) instead #include <WinAPIFiles.au3> #include <WinAPIShellEx.au3> _WinAPI_Wow64EnableWow64FsRedirection(False) Local $sSystem32 = _WinAPI_ShellGetKnownFolderPath($FOLDERID_System) If FileExists($sSystem32 & "\dsac.exe") Then MsgBox("","","the file exists! and we are happy :)") Else MsgBox("","","please download microsoft remote administration tools",3) ShellExecute("https://www.microsoft.com/en-us/download/details.aspx?id=45520") EndIf Another way, is the use the Sysnative folder. In this case, you don't need to disable the WOW6432 redirection : Local $sSystem32 = FileExists(@WindowsDir & "\sysnative") ? @WindowsDir & "\sysnative" : @SystemDir If FileExists($sSystem32 & "\dsac.exe") Then MsgBox("","","the file exists! and we are happy :)") Else MsgBox("","","please download microsoft remote administration tools",3) ShellExecute("https://www.microsoft.com/en-us/download/details.aspx?id=45520") EndIf Professor_Bernd 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
RTFC Posted November 8, 2017 Posted November 8, 2017 (edited) 2 hours ago, jguinch said: @SystemDir, because it always returns the Syswow64 path (with a 32 bits running script) @jguinch: This is true, but when I run this little test based upon your first example: #include <WinAPIFiles.au3> #include <WinAPIShellEx.au3> _WinAPI_Wow64EnableWow64FsRedirection(True) $sSystem32 = _WinAPI_ShellGetKnownFolderPath($FOLDERID_System) MsgBox(0,$sSystem32,@systemdir) _WinAPI_Wow64EnableWow64FsRedirection(False) $sSystem32 = _WinAPI_ShellGetKnownFolderPath($FOLDERID_System) MsgBox(0,$sSystem32,@systemdir) _WinAPI_ShellGetKnownFolderPath appears equally insensitive to redirection, always returning C:\WINDOWS\system32 (at least on my x64 machine+OS running a 32-bit script). I interpreted your response as suggesting that ShellGetKnownFolderPath would reflect the redirection status, or did I miss/misinterpret something? 2 hours ago, jguinch said: {unable to delete this silly box} Edited November 8, 2017 by RTFC My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O
jguinch Posted November 8, 2017 Posted November 8, 2017 @RTFC : with or without the redirection, the System directory is always c:\windows\system32. With a 32 bits script, you can use $FOLDERID_SystemX86 the get x86 system path. But in this case, $FOLDERID_System returns the desired value Earthshine 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
argumentum Posted November 8, 2017 Posted November 8, 2017 (edited) ConsoleWrite( EnvGet("SystemRoot") & "\system32" & @CRLF ) Anyway, @legend, use FileGetSize(), maybe ? Edited November 8, 2017 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
RTFC Posted November 12, 2017 Posted November 12, 2017 @jguinch: Ah, thanks for the clarification. My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now