JohnSAutoIt Posted May 10, 2010 Posted May 10, 2010 (edited) Running programs and opening files is one of the most fundamental aspects of scripting but I've had the greatest difficulty finding information. I don't think any of the AutoIt or Wiki tutorials show examples and searching the forum was a waste of much time (too many inapplicable results). Ditto for Example Scripts. Very frustrating. "FileOpen" would seem to be the most obvious but that is text only. "Run" is the next most obvious but seems to apply to the primary files only eg exe. After much time I found "ShellExecute". That did not work - it opened the jpg file with MSPaint which I assume must be the baseline default for XP but not my configured "File Types" default, Irfanview. I experimented with parameters for the file string variable "$file" attached to the exe, "C:\Program Files\IrfanView\i_view32.exe $file". That did not work so I changed $file to a specific file/path as text. That worked. Command Line parameters are not mentioned in the Help for the "Run" command which seems to be a strange omission. Getting back to where I am now, Run("C:\Program Files\IrfanView\i_view32.exe $file") does not work because the $file is not converted to text. I've tried incorporating the String command String($file). How do I get this to work? Edited May 10, 2010 by JohnSAutoIt
evilertoaster Posted May 10, 2010 Posted May 10, 2010 (edited) If configured properly, ShellExecute() should do the same thing as "doubble click" on a file. Are you sure JPEG are not set to IfanView by default? If you have to use the workaround you're trying, it would be Run("C:\Program Files\IrfanView\i_view32.exe " & $file) Edited May 10, 2010 by evilertoaster
l3ill Posted May 10, 2010 Posted May 10, 2010 Or this: ShellExecute('i_view32.exe', $mypic, "", "", @SW_MAXIMIZE) My Contributions... Reveal hidden contents SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
JohnSAutoIt Posted May 10, 2010 Author Posted May 10, 2010 Thanks for the responses. I used the "Run" and it worked fine. I suppose I should have thought of joining the variable with the "&". It did not cross my mind. Double-clicking a jpeg opens it in Irfanview as it is supposed to. There must be an issue somewhere with the "File Types" configuration.
MHz Posted May 11, 2010 Posted May 11, 2010 On 5/10/2010 at 11:42 PM, 'JohnSAutoIt said: Double-clicking a jpeg opens it in Irfanview as it is supposed to. There must be an issue somewhere with the "File Types" configuration. You can check that in a command prompt by typing: assoc .jpg and the output I get is: .jpg=jpegfile So now check "jpegfile" from output above: ftype jpegfile and the output I get is: jpegfile=rundll32.exe C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen %1 which is the Windows Picture And Fax Viewer. ShellExecute($file) returns the Windows Picture And Fax Viewer for me. Irfanview may have changed the association and it is perhaps incorrect.
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