Tigerweld

check for File

9 posts in this topic

Trying to check for file exists, but for some reason it isn't working and I think it may be something to do with Windows 7 permissions?  Anyone else run into this problem?  I get File does not exist no matter what.

If FileExists ("c:\windows\system32\test.txt") Then
    MsgBox(4096, "Yes", "File does exist")
Else
    MsgBox(4096, "No", "File does not exist")
EndIf

 

Share this post


Link to post
Share on other sites



Add this line to the top of your script

#RequireAdmin

 


My Scripts:

False Positive Reporter - Mass email all anti virus vendors with an attachment of your program for easy whitelisting.

PortableApps.com App Creation Wizard  - A simple GUI-based Wizard for creating PortableApps.

AutoISO  - Automatic ISO Image creation using ImgBurn.

SoundBoard - Play any song or sound you want at the press of a hotkey

Share this post


Link to post
Share on other sites

still comes back as "file does not exist"

Share this post


Link to post
Share on other sites

then do try to compile again

e74979ffec104463a486343e30d435b2.png

Share this post


Link to post
Share on other sites

compiling it as x64 did the trick!  thanks.  Will this script work on a x86 computer?

Share this post


Link to post
Share on other sites

no for x86

FileExists(@SystemDir & "\test.txt")

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

2 hours ago, Tigerweld said:

compiling it as x64 did the trick!  thanks.  Will this script work on a x86 computer?

From the docs:

Running the 32-bit version of AutoIt on a x64 System

For Files, Windows has a special redirection mechanism for some system directories :

Directories 32-bit Value 64-bit Value
@SystemDir @WindowsDir & "\System32" @WindowsDir & "\SYSWOW64"
@ProgramFilesDir {SystemDrive} & "\Program Files (x86)" {SystemDrive} & "\Program Files"

It's possible to access the 64-bit version of those directories by disabling the redirection mechanism.

#include <WinAPIFiles.au3>

_WinAPI_Wow64EnableWow64FsRedirection(True)

Additional information can be found at MSDN.

For registry interaction, use HKCR64 or HKLM64 to bypass the redirection mechanism see Registry Functions documentation.

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now