Jump to content

How To See If File Exist In Users Profile?


Recommended Posts

If FileExists(@UserProfileDir & "/horde/rainmain.exe") then

run("%appdata%/horde/rainmain.exe")

else

msgbox(0,"Where did it go george?","Can't find what you want")

endif

this is supposed to run the file if found in the users %appdata% , if not found then display message.. but the stupid thing is that it doesn't look at all.

Edited by slightly_abnormal
Link to comment
Share on other sites

If FileExists(@UserProfileDir & "/horde/rainmain.exe") then

run("%appdata%/horde/rainmain.exe")

else

msgbox(0,"Where did it go george?","Can't find what you want")

endif

this is supposed to run the file if found in the users %appdata% , if not found then display message.. but the stupid thing is that it doesn't look at all.

Works great for all my Linux boxes, but using forward-slashes in a Windows CMD shell blows up a lot of things. Try it with back-slashes? :)

If FileExists(@UserProfileDir & "\horde\rainmain.exe") then
run("%appdata%\horde\rainmain.exe") 
else
msgbox(0,"Where did it go george?","Can't find what you want")
endif
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Moderators

Is this what you are trying to do?

Local $AppLocation = @AppDataDir & "\horde\rainmain.exe"
If FileExists($AppLocation) then
    Run($AppLocation)
Else
    MsgBox(0,"Where did it go george?","Can't find what you want")
EndIf
Your back slashes were off a tad too :)

Edit:

PsaltyDS beat me too it, serves me right to answer the phone 1st :mellow:

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Is this what you are trying to do?

Local $AppLocation = @AppDataDir & "\horde\rainmain.exe"
If FileExists($AppLocation) then
    Run($AppLocation)
Else
    MsgBox(0,"Where did it go george?","Can't find what you want")
EndIf
Your back slashes were off a tad too :>

Edit:

PsaltyDS beat me too it, serves me right to answer the phone 1st :>

:) I DON'T BELIEVE IT!!! :mellow:

I got a reply typed faster than SmOke_N! :> Go Me! :) Party time! :o

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

FYI, you would probably need Opt("ExpandEnvStrings", 1) at the top of the script if you decided to use %appdata% anyway:

Changes how literal strings and % symbols are interpreted. By default strings are treated literally, this option allows you to use %environment% variables inside strings, e.g., "The temp directory is: %temp%".

1 = expand environment variables (similar to AutoIt v2)

0 = do not expand environment variables (default)

Without this option the usual way would be: "The temp directory is: " & EnvGet("temp")

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

  • 3 weeks later...

coolness, it's always best to add error handling. Let's say he puts it out w/o the If Filexists.... part. If rainman.exe doesn't exist, it throws an auto-it error box & closes. Most people wouldn't know what that meant, and claim there was a bug in his code. If he keeps the If FileExists... then he can add his own error box like so

MsgBox(4096, "Houston, we have a problem",@AppDataDir & "\horde\rainman.exe doesn't exist, please install the program before running this.")
Exit

~cdkid

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

  • Moderators

Why not just choose to run it, then make a spot in the script, to where it will take down the air box, after it comes up. Answer that smartass, it's one less click.

Do you have an example of what you mean?... And I don't think cdkid was being a smart ass, more informative than anything else. Also, you don't "have" to use a MsgBox() for the "Else" statement, that can be anything, we generally put that there so that there for debugging purposes, but most will have it either Exit or go to another function or whatever they want to accomplish if in fact it doesn't exist.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

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