JoneZ Posted August 2, 2006 Posted August 2, 2006 I am a newbie. But i am sure this must be possible... Can i get autoit to open any file i like without saying what program needs to open it? When you click on a file you dont have to know what program should open it. The OS already knows because the file type has been assigned to that application. I know that the following works. $LocationAndApplication2OpenWithEXE = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" $ItemLocationAndNameToOpen=@WorkingDir &"\FFT\school_FFT_DB_SCH.mdb" Run('"' & $LocationAndApplication2OpenWithEXE & '" "' & $ItemLocationAndNameToOpen & '"') Or the very simple example in the help file Run("Notepad.exe", "", @SW_MAXIMIZE) .. But is there a way not to say the program and just specify the file? I want to open word, access and excel files. But if the autoit is run on a machine with a different version of office i'd have to code all the locations of the various versions of office. Is there a way to solve this Thanks in advance
/dev/null Posted August 2, 2006 Posted August 2, 2006 (edited) .. But is there a way not to say the program and just specify the file?I want to open word, access and excel files. But if the autoit is run on a machine with a different version of office i'd have to code all the locations of the various versions of office.Is there a way to solve this Try this: Run(@ComSpec & ' /c start ' & $filename, '', @SW_HIDE)start knows most of the file associations.CheersKurt Edited August 2, 2006 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Don N Posted August 2, 2006 Posted August 2, 2006 You could search for the excel/access/word exe's on the local computer. Then enter <exe> <filename> at the command prompt This method will only require you to know the name of the executables which should be standard. _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper
BigDod Posted August 2, 2006 Posted August 2, 2006 #include <Process.au3> _RunDos("start d:\autoit\smurf.tif") 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
JoneZ Posted August 7, 2006 Author Posted August 7, 2006 Thanks for your help. It works fine for text files. But i'm now trying to open an access database. And nothing happens. No error or anything. I've tried both $filename = @WorkingDir &"\FFT\database.mdb" Run(@ComSpec & ' /c start ' & $filename, '', @SW_HIDE) And... _RunDos("start H:\Autoit\FFT\database.mdb") Any ideas? Thanks for the help so far
nfwu Posted August 7, 2006 Posted August 7, 2006 $filename = @ScriptDir &"\FFT\database.mdb" $CodeName = RegRead("HKEY_CLASSES_ROOT\.mdb", "") $thingtorun = RegRead("HKEY_CLASSES_ROOT\"&$CodeName&"\shell\Open\command", "") $thingtorun = StringReplace($thingtorun, "%1", $filename) Run($thingtorun) #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode()
/dev/null Posted August 7, 2006 Posted August 7, 2006 It works fine for text files. But i'm now trying to open an access database. And nothing happens. No error or anything.Any ideas?Three things:1.) is M$ Access installed on your system?2.) what happens if you double click a *.mdb file?3.) what happens if you run the start command manually?CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
nfwu Posted August 7, 2006 Posted August 7, 2006 Another thing. I noticed that you are using @WorkingDir. Did you mean @ScriptDir? #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode()
JoneZ Posted August 7, 2006 Author Posted August 7, 2006 Thanks for that i'll give it a try. Just looked in the help file and yes @ScriptDir is what i need to use. Thanks for picking up on that Cheers Jonez
JoneZ Posted August 7, 2006 Author Posted August 7, 2006 Three things:1.) is M$ Access installed on your system?2.) what happens if you double click a *.mdb file?3.) what happens if you run the start command manually?CheersKurt1) Yes of course. I'm lame at Autoit but i'm not that lame 2) If i double click a *.mdb file it open in Access3) If you mean do a Start> Run > Type the path to the file and click ok. Then that opens the file in Access too.CheersJonez
JoneZ Posted August 7, 2006 Author Posted August 7, 2006 $filename = @ScriptDir &"\FFT\database.mdb" $CodeName = RegRead("HKEY_CLASSES_ROOT\.mdb", "") $thingtorun = RegRead("HKEY_CLASSES_ROOT\"&$CodeName&"\shell\Open\command", "") $thingtorun = StringReplace($thingtorun, "%1", $filename) Run($thingtorun) #) Coool! That opens the file! Thanks for that. Any ideas why my other code doesnt work? I was trying to do it as simply as possible and that works fine for text files and even word *.doc files. Cheers
JoneZ Posted August 7, 2006 Author Posted August 7, 2006 $filename = @ScriptDir &"\FFT\database.mdb" $CodeName = RegRead("HKEY_CLASSES_ROOT\.mdb", "") $thingtorun = RegRead("HKEY_CLASSES_ROOT\"&$CodeName&"\shell\Open\command", "") $thingtorun = StringReplace($thingtorun, "%1", $filename) Run($thingtorun) #) As i said that works fine for *.mdb files. If i wanted to open a word document would i just do. $filename = @ScriptDir &"\FFT\document.doc" $CodeName = RegRead("HKEY_CLASSES_ROOT\.doc", "") $thingtorun = RegRead("HKEY_CLASSES_ROOT\"&$CodeName&"\shell\Open\command", "") $thingtorun = StringReplace($thingtorun, "%1", $filename) Run($thingtorun) This opens Word but the file doesnt open at all. Cheers for the help
/dev/null Posted August 7, 2006 Posted August 7, 2006 (edited) 1) Yes of course. I'm lame at Autoit but i'm not that lame well, we do have some really "strange" people on this forum. I thought it's better to eliminate the obvious problems first 2) If i double click a *.mdb file it open in AccessWhat's the output of: assoc | find "mdb"and ftype | find "access"3) If you mean do a Start> Run > Type the path to the file and click ok. Then that opens the file in Access too.Actually no. Start > Run > cmd.exe and then "start H:\Autoit\FFT\database.mdb".CheersKurt Edited August 7, 2006 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
nfwu Posted August 7, 2006 Posted August 7, 2006 Try this: Func _OpenFile($extention, $file) $CodeName = RegRead("HKEY_CLASSES_ROOT\"&$extention, "") $thingtorun = RegRead("HKEY_CLASSES_ROOT\"&$CodeName&"\shell\Open\command", "") $thingtorun = StringReplace($thingtorun, "%1", $file) If Not @extended Then $thingtorun = $thingtorun & " " & $file Run($thingtorun) EndFunc May fail on certain types of files, as I only taken into account one of the ways inwhich assosiations are stored. _OpenFile(".doc", @ScriptDir &"\FFT\document.doc") #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode()
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now