Jump to content

FileExists issue trying to distinguish between a 32 bit and a 64 bit computer version


Recommended Posts

Hello,

I am new to Autoit.

I am trying to establish via autoit FileExists() whether I am working on a 32 bit computer version or a 64 bit computer version.

i am testing the Windows Sidebar path location on a 32 bit version and on a 64 bit version with one Autoit code file

each computer bit version containing the Windows Sidebar path in a different folder !

aim;

code will direct each version (bit) to its appropriate coding functions.

However this will Not work as it does not make the version distinction:

i.e.,

if tested on a 64 bit version it would output as follows:

This is a 32 bit version computer. FileExist returned: 1

and,

This is a 64 bit version computer. FileExist returned: 1 (should only be this output !!!)

On a 64 bit version computer the Windows Sidebar path (and executable file) is ONLY located here:

"C:\Program Files (x86)\Windows Sidebar\sidebar.exe" (!)

Here is my code:

(starts beneath dotted area)

--------------------------------------------

#include <MsgBoxConstants.au3>

;Assign the 32 bit version file path to a variable.
Local $sFilePath32 = "C:\Program Files\Windows Sidebar\sidebar.exe"

;Check if file exists.
Local $iFileExists32 = FileExists($sFilePath32)

;Display a message after checking the returned value.
If $iFileExists32 Then
    MsgBox($MB_SYSTEMMODAL, "", "This is a 32 bit version computer." & @CRLF & "FileExist returned: " & $iFileExists32)
Else
    MsgBox($MB_SYSTEMMODAL, "", "The file doesn't exist." & @CRLF & "FileExist returned: " & $iFileExists32)
EndIf

 

;Assign the 64 bit version computer file path to a variable.
Local $sFilePath64 = "C:\Program Files (x86)\Windows Sidebar\sidebar.exe"

;Check if file exists.
Local $iFileExists64 = FileExists($sFilePath64)

;Display a message after checking the returned value.
If $iFileExists64 Then
    MsgBox($MB_SYSTEMMODAL, "", "This is a 64 bit version computer." & @CRLF & "FileExist returned: " & $iFileExists64)
Else
    MsgBox($MB_SYSTEMMODAL, "", "The file doesn't exist." & @CRLF & "FileExist returned: " & $iFileExists64)
 EndIf

;Please Help, Thank You. :shifty:

 

 

 

 

Link to comment
Share on other sites

anyway  FileExists() is important to me in case i search for the existence of a file.

In addition,

It would be most appreciated if you could debug my code and explain where I went wrong. thank you very much.

Link to comment
Share on other sites

  • Moderators

@dzur you have been pointed to the @OSArch macro, and a simple search of the forum would show you many, many examples of this in use. Here is one from just a few days ago:

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Developers

@dzur, sorry for being bold with you but it would be nice if you first think before shooting the posts from the hip! ;)

Enjoy,
Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

@dzur I sent you a PM. Stop spamming this thread and read the help file. The syntax you need is very clearly stated.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

No, I am sorry. The Help file DOES NOT ! show any working example:

'Returns one of the following: "X86", "IA64", "X64" - this is the architecture type of the currently running operating system'

What am I supposed to understand from this ?

I simply google along in order to come up with how to check a 32 bit version computer.

I have no intention whatsoever to spam the thread. You do not know me.

As a NewComer to autoit i am simply at a loss. !

Goodbye.

Link to comment
Share on other sites

  • Moderators

@dzur The help file shows you the syntax:

Quote
@OSArch Returns one of the following: "X86", "IA64", "X64" - this is the architecture type of the currently running operating system.

So your if statement should be:

If @OSArch = "X64" Then
   ;Do Something for 64bit machines
Else
   ;Do Something for 32bit machines
EndIf

Not sure how to make it any clearer...

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

@dzur If you can't understand something as simple as what OS architecture each of those is referencing, perhaps you shouldn't BE writing scripts until you do understand what they are.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Developers

Ok, back to the THINK FIRST topic. What again does the helpfile state the returned value options are for this macro? does it contain "32"?

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Putting an end to this madness:

If Is32bit() Then ; If the computer is 32 bit...
    ; Do something if the computer is 32 bit.
Else ; If the computer is not 32 bit...
    ; Do something if the computer is 64 bit.
EndIf

Func Is32bit()
    Return @OSArch = "X86"
EndIf

Just copy paste the last 3 lines at the end of your code to use the Is32bit function.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

  • Developers
1 minute ago, TheDcoder said:

Putting an end to this madness:

No it doesn't and the only smart thing would have been to stay out of this thread!

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

As the OP has delivered a long diatribe regarding how great a programmer he is via PM, and has asked me to close his account, I see no reason for this thread to continue.

@TheDcoder I agree with Jos, you continue to have an issue with engaging your brain before you engage your keyboard. You would have been better served had you stayed out of the thread rather than muddying it further.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...