Jump to content

Recommended Posts

Posted

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

Posted (edited)

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
  • Moderators
Posted

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)
Posted (edited)

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
Posted

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

You have to quote the file path to avoid issues with spaces:

$file = 'X:\Path With Space\file.txt'
Run(@comSpec & ' /c start "' & $file & '"', '', @SW_HIDE)

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
×
×
  • Create New...