Jump to content

How to run/open a file


Recommended Posts

Hi,

I want to open a txt file with my autoit script. The script produces a log file and at the end of the script I want to execute/open/run this logfile. It should just appear in the standard application that is connected with the filetype.

I tried run but it only executes files like exe/bat etc ..

So what can I do ?

Thanks

Link to comment
Share on other sites

Well, opening in the standard application is not a easy thing to do. It would be best if you could just use notepad for this application. (Look in the AutoIt helpfile for Tutorial.)

If you want to know what the standard application is you have do this (Untested):

RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithList", "a")
Edited by Manadar
Link to comment
Share on other sites

  • Moderators

Well, opening in the standard application is not a easy thing to do. It would be best if you could just use notepad for this application. (Look in the AutoIt helpfile for Tutorial.)

If you want to know what the standard application is you have do this (Untested):

RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithList", "a")
Its not that hard, just use something like this:

$sPath = "path to your text file"
Run("Notepad.exe " & $sPath)
Link to comment
Share on other sites

Hi

Just use:

Run(@comSpec & " /c start "& @Scriptdir & "\" & "yourfile.txt", "", @SW_HIDE)

ofcourse: change the ...@Scriptdir & "\" & "yourfile.txt"... to the proper filepath...

Note:

using the suggested Run("Notepad.exe "...)

Remember the name of "Notepad" might be 'English-windows-versions-ONLY"...

HTH

Edited by heibel
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...