Jump to content

Open a file with it's associated program


Recommended Posts

I need to know how can I open a file (with extension .exe, .doc, .txt, .htm, etc) with it's associated program (Excel, Word, Notepad, Internet Explorer, etc) I tried with this

Run(@ComSpec & " /c start " & $file, @SW_SHOW)

but it only work witn Internet Explorer.

Is there a more generic way to do this? without knowing the program associated to the file I want to open.

thanks in advance

Link to comment
Share on other sites

I need to know how can I open a file (with extension .exe, .doc, .txt, .htm, etc) with it's associated program (Excel, Word, Notepad, Internet Explorer, etc) I tried with this

Run(@ComSpec & " /c start " & $file, @SW_SHOW)

but it only work witn Internet Explorer.

Is there a more generic way to do this? without knowing the program associated to the file I want to open.

thanks in advance

Try _RunDos

#include <Process.au3>
$rc = _RunDos("start d:\autoit\uptime.au3")


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Try _RunDos

#include <Process.au3>
$rc = _RunDos("start d:\autoit\uptime.au3")
I Found that the problem is with Directories or filenames that has space in its names, so I can solve the directories problem executing the function FileChangeDir() previously and then excute _RunDos() but I still have problem with filenames that has spaces. I Tried adding quotation but doesn't work:

$rc = _RunDos('"start d:\autoit\up time.au3"')

Or

$rc = _RunDos('start "d:\autoit\up time.au3"')

Any suggestion

Link to comment
Share on other sites

I Found that the problem is with Directories or filenames that has space in its names, so I can solve the directories problem executing the function FileChangeDir() previously and then excute _RunDos() but I still have problem with filenames that has spaces. I Tried adding quotation but doesn't work:

$rc = _RunDos('"start d:\autoit\up time.au3"')

Or

$rc = _RunDos('start "d:\autoit\up time.au3"')

Any suggestion

Try

#include <Process.au3>
$prog = FileGetShortName("d:\autoit\up time.au3")
$rc = _RunDos("start " & $prog)


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Try

#include <Process.au3>
$prog = FileGetShortName("d:\autoit\up time.au3")
$rc = _RunDos("start " & $prog)
Many Thanks BigDog, it works now

Many thanks also to all the peoples that colaborates in Autoit forum

Link to comment
Share on other sites

Many Thanks BigDog, it works now

Many thanks also to all the peoples that colaborates in Autoit forum

The name is BigDod not BigDog but we all make typos.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

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...