Jump to content

How do i run a precreated txt document


 Share

Recommended Posts

Okay, I already know that this is possible with

Run("Notepad.exe" "Test.txt")

However, this seems to only work if the .txt document is located directly within the main autoit folder

I would like to know how i can make it know exactly where the .txt document is and locate it and run it.

Any help would be greatly appreciated

Edited by Joosh
Link to comment
Share on other sites

You could send Notepad a full path like so:

Run('Notepad.exe "C:\My Documents\Test.txt"')

Or alternatively if you have the filename in a variable:

$File = "C:\My Documents\Test.txt"
Run('Notepad.exe "' & $File & '"')
Link to comment
Share on other sites

Okay thats helpful in the short term but this program is going to be carted around and moved from computer to computer each time probably being placed in a different directory, the .txt file and .exe file will both be bundled in the same folder, how can i make autoit understand that the .txt file is in the same folder as the .exe that is being run and go from there?

Link to comment
Share on other sites

$File = @ScriptDir & "\SomeFile.txt"
Run('Notepad.exe "' & $File & '"')

otherwise in the exe u could place this

$file = @WorkingDir & "\SomeFile.txt"
Run('Notepad.exe "' & $File & '"')

coded with beta .65

@WorkingDir = Current/active working directory. (Result does not contain a trailing backslash)

@ScriptDir = Directory containing the running script. (Result does not contain a trailing backslash)

have to use a trainling backslash as there isnt one included...

Cheers

Edited by WSCPorts
http://www.myclanhosting.com/defiasVisit Join and contribute to a soon to be leader in Custumized tools development in [C# .Net 1.1 ~ 2.0/C/C++/MFC/AutoIt3/Masm32]
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...