# how to open a file like doubleclick does ....

## Recommended Posts

Hummm basic question ...

I try to open file like 2click does on an icon.

( files like click an excel file or a word document .... )

I played with run command but I need the full path of the application ...

Is this a command somewhere that do that ?

:">

##### Share on other sites

First of all, you have to know the full path....Otherwise how are you goin to indicate AutoIt where the file is?

Try this and tell me :

Run(@ComSpec & "/c start " & $file ,"",@SW_HIDE) Where$file is the full path of your file e.g.

$file="C:\Program Files\text.txt" C ya Edited by hgeras #### Share this post ##### Link to post ##### Share on other sites Use the generic Run statement for com, lnk, exe(programs only) FileOpen for text files IniCreate, write, etc for Ini's besides that Shellexecute or use Larrys Au3record to doubleclick on the desired file #### Share this post ##### Link to post ##### Share on other sites First of all, you have to know the full path....Otherwise how are you goin to indicate AutoIt where the file is? Try this and tell me : Run(@ComSpec & "/c start " &$file ,"",@SW_HIDE)

Where $file is the full path of your file e.g.$file="C:\Program Files\text.txt"

C ya

<{POST_SNAPBACK}>

:">

Im please that work for you ....

Here I'm not able to open the file if along the path of the file I have folder name with space.

run( @ComSpec & " /c start C:\Program Files\txt.txt", "", @SW_HIDE )

I tried putting "" around filename but it didn't work ....

run( @ComSpec & " /c start ""C:\Program Files\txt.txt""", "", @SW_HIDE )

How are you doing it ?

##### Share on other sites

AutoIt Smith had it right. you do not use the run/comspec to open a text file

in this example. You use the Word/excell program followed by the text file you wish to open

$program_location = @ProgramFilesDir & "\Folder\program.exe"$file_location = "C:\Desktop\text.txt"

Run( $program_location & " " &$file_location & "")

to find the locations

right click on the short-cut

left click properties

copy the location (ex C:\desktop\...)

$f = "copy of xyz.xls" run( "cmd /c " & " """ &$d & $f & """ ", "", @SW_HIDE ) Edited by JoeCool #### Share this post ##### Link to post ##### Share on other sites the problem for me is there was no space between "$d & $f". this worked(just added the space using the double quotes) run( "cmd /c " & " """ &$d & " """ & $f & """ ", "", @SW_HIDE ) 8) #### Share this post ##### Link to post ##### Share on other sites Hummm basic question ... I try to open file like 2click does on an icon. ( files like click an excel file or a word document .... ) I played with run command but I need the full path of the application ... Is this a command somewhere that do that ? :"> <{POST_SNAPBACK}> I'm bored, so I'll try writing a script to query a few reg keys or a Windows .dll to try and get that to work through AutoIt. I thought I saw a reg key the other day while roaming the registry that might be of use. Check back with me in a few days if I haven't re-posted here. "... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster." #### Share this post ##### Link to post ##### Share on other sites I'm bored, so I'll try writing a script to query a few reg keys or a Windows .dll to try and get that to work through AutoIt. I thought I saw a reg key the other day while roaming the registry that might be of use. Check back with me in a few days if I haven't re-posted here. <{POST_SNAPBACK}> Thanks but I found what I need $d = "C:\Program Files\"
$f = "copy of xyz.xls" run( "cmd /c " & " """ &$d & \$f & """ ", "", @SW_HIDE )

some info there from Bill

http://www.microsoft.com/resources/documen.../en-us/cmd.mspx

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

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...