dzur

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

19 posts in this topic

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:

 

 

 

 

Share this post


Link to post
Share on other sites



Can you be more specific please, giving a full working example. I am new to Autoit, thank you.

Share this post


Link to post
Share on other sites

if OSArch....????

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

@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:

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

If @OSArch = "X64" Then... (for a 64 bit version computer).

But for a 32 bit version ?

If @OSArch = "32" Then...  ???

thnx.

 

 

Share this post


Link to post
Share on other sites

Syntax... Syntax...Syntax....

thnx.

Share this post


Link to post
Share on other sites

@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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

@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...


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Mr.JLogan3o13 Sir,

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

I understand above code very clealy.

but,

If @OSArch= "32" then

;Do Something for 32bit machines

Else

;Do Something for 64bit machines

EndIf

WRONG CODE ? ="32" or should it be "32 bit" or should it be "x32' or...

thnx ()

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

How many different ways do you need it explained to you?!

Dense.png

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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.

2 people like this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.