ne0trace Posted January 7, 2008 Share Posted January 7, 2008 Hello, I am currently writing a script for installing Adobe After Effects. What I wanted to include before the installer is running "blind" is a script which checks if the program directory (c:\program files\adobe\adobe after effects 7.0) already exists. As we are having a mixed environment of x86/x64 Windows XP Systems it has to first check if the OS is 64bit (the use \program files(x86)\adobe\...) or else, use the usual directory. I've already found the following variable: @ProgramFilesDir As I am a complete newbie to Autoit (using it since friday), I don't know much about using the "if function". Could someone please help me? Felix Link to comment Share on other sites More sharing options...
JerryD Posted January 7, 2008 Share Posted January 7, 2008 (edited) First, I'm not familiar with the 64 bit environment, so I'm making some assumptions that might be off. The macro @ProgramFilesDir should evaluate to wherever the correct directory based on the OS, so it should evaluate to "C:\Program Files" under XP 32 bit, and "C:\Program Files(x86)" under XP 64 bit. So, you should just need one statementIf FileExists ( @ProgramFilesDir & '\adobe\adobe after effects 7.0' ) Then ; your code here EndIffor either OS to determine if the directory exists. Edited January 7, 2008 by JerryD Link to comment Share on other sites More sharing options...
ne0trace Posted January 7, 2008 Author Share Posted January 7, 2008 (edited) Thank you for your fast response... I just want to be sure that I understood you correctly. Your code checks whether the directory X:\Program Files\... exists and if positive, continues/stops the script? What makes the situation so complicated (imho) is that AE7 (After Effects 7) is beeing installed to "C:\Program Files" on x86 OS and to "C:\Program Files (x86)" on x64 OS's. But windows variable is different on each OS Version. I pasted the variables directly from Windows: ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) Or am I overcomplicating things here? thank you Felix Edited January 7, 2008 by ne0trace Link to comment Share on other sites More sharing options...
Pioneer5250 Posted January 7, 2008 Share Posted January 7, 2008 found this topic herehttp://www.autoitscript.com/forum/index.ph...6294&hl=x64SmOke_N wrote a function to dtermine what os is runningmaybe something like this might helpDim $ProgramFilesDir If _OSBit2() = 64 Then $ProgramFilesDir = @HomeDrive & "\Program Files (x86)" Else $ProgramFilesDir = @HomeDrive & "\Program Files" EndIf If FileExists($ProgramFilesDir & "\adobe\adobe after effects 7.0") Then ;Code EndIf Func _OSBit2() Local $tOS = DllStructCreate("char[256]") Local $aGSWD = DllCall("Kernel32.dll", "int", "GetSystemWow64Directory", "ptr", DllStructGetPtr($tOS), "int", 256) If IsArray($aGSWD) And DllStructGetData($tOS, 1) Then Return 64 Return 32 EndFunc Link to comment Share on other sites More sharing options...
ne0trace Posted January 7, 2008 Author Share Posted January 7, 2008 (edited) I rewrote the function to make a quick check if it is working as proposed. The directory i try to check is "C:\Programme\Adobe\Adobe After Effects 7.0" and the OS is 32bit. I thought that output of the script should have been "Directory Exists". Instead it reports that the directory isn't existing. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Dim $ProgramFilesDir If _OSBit2() = 64 Then $ProgramFilesDir = @HomeDrive & "\Program Files (x86)" Else $ProgramFilesDir = @HomeDrive & "\Program Files" EndIf If FileExists($ProgramFilesDir & "\Adobe\Adobe After Effects 7.0\") Then MsgBox(64, "After Effects 7.0 Install", "IT EXISTS") Else MsgBox(64, "Test", "IT DOESN'T EXIST") EndIf Func _OSBit2() Local $tOS = DllStructCreate("char[256]") Local $aGSWD = DllCall("Kernel32.dll", "int", "GetSystemWow64Directory", "ptr", DllStructGetPtr($tOS), "int", 256) If IsArray($aGSWD) And DllStructGetData($tOS, 1) Then Return 64 Return 32 EndFunc Any idea what I did wrong? Felix Edited January 7, 2008 by ne0trace Link to comment Share on other sites More sharing options...
JerryD Posted January 7, 2008 Share Posted January 7, 2008 (edited) What happens if you just do this without any other code:If FileExists ( @ProgramFilesDir & "\Adobe\Adobe After Effects 7.0\") Then MsgBox ( 64, "After Effects 7.0 Install", "IT EXISTS" ) Else MsgBox ( 64, "Test", "IT DOESN'T EXIST" ) EndIf Note that's @ProgramFilesDir - the MACRO - NOT a Vairable.As I originally said, @ProgramFilesDir should automatically evaluate correctly. Does it? Edited January 7, 2008 by JerryD Link to comment Share on other sites More sharing options...
ne0trace Posted January 7, 2008 Author Share Posted January 7, 2008 What happens if you just do this without any other code: If FileExists ( @ProgramFilesDir & "\Adobe\Adobe After Effects 7.0\") Then MsgBox ( 64, "After Effects 7.0 Install", "IT EXISTS" ) Else MsgBox ( 64, "Test", "IT DOESN'T EXIST" ) EndIf Note that's @ProgramFilesDir - the MACRO - NOT a Vairable. As I originally said, @ProgramFilesDir should automatically evaluate correctly. Does it? It recognizes the directory correctly: "IT EXISTS". So the OS_bit function isn't working in this case? Felix Link to comment Share on other sites More sharing options...
ne0trace Posted January 7, 2008 Author Share Posted January 7, 2008 I've found a way that works (though not elegant at all)... If FileExists ( "C:\Program Files\Adobe\Adobe After Effects 7.0\") Or FileExists ( "C:\Program Files(x86)\Adobe\Adobe After Effects 7.0\") OR FileExists ( "C:\Programme\Adobe\Adobe After Effects 7.0\") Then MsgBox ( 64, "After Effects 7.0 Install", "IT EXISTS" ) Else MsgBox ( 64, "Test", "IT DOESN'T EXIST" ) EndIf Felix Link to comment Share on other sites More sharing options...
JerryD Posted January 7, 2008 Share Posted January 7, 2008 (edited) Never mind... Edited January 7, 2008 by JerryD Link to comment Share on other sites More sharing options...
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