RegiOween Posted April 10, 2006 Share Posted April 10, 2006 Hi, folks! Is there some way to run associated files that are not executable directly using the RUN function? For example: Run("C:\PATH\FILE.EXT", "C:\PATH") With the command above, I receive the message "Error: Unable to execute the external program." It seems that RUN just works with executable files like EXE, COM, BAT, etc. I tried to use a workaround like this: Run(@COMSPEC & " /c C:\PATH\FILE.EXT", "C:\PATH", @SW_HIDE) This command works to execute FILE.EXT using CMD.EXE, but the flag @SW_HIDE doesn't work the way I want, since it hides CMD.EXE window and not FILE.EXT window. My main purpose is run FILE.EXT in a hidden window. If anyone knows some way to do that, even if I have to use some external tool, please explain me how. Thanks in advance. Reginaldo O. Andrade PS: Sorry about possible english errors, I'm from Brazil :-) Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted April 10, 2006 Moderators Share Posted April 10, 2006 (edited) Try using this for your run cmd to run the associated program. $path = "path to the file you want to run" Run(@ComSpec & " /c Start " & $path, "", @SW_HIDE) Then you could do a WinWait() and a WinSetState() to hide the program window. Also you may want to look at WinWaitDelay to shorten the delay in the Window related commands. You could try putting this at the top of your script. Opt("WinWaitDelay", 75) Edited April 10, 2006 by big_daddy Link to comment Share on other sites More sharing options...
MHz Posted April 10, 2006 Share Posted April 10, 2006 You are correct in what filetypes that Run() executes as it is state on the help page for Run().Have a look at Freqently Asked Question Number 6.http://www.autoitscript.com/autoit3/docs/faq.htm#6Execute the program that is associated with the file to execute the file, and since you are using the correct program with Run(), the the hide flag should work unless the program does not want to hide. Link to comment Share on other sites More sharing options...
RegiOween Posted April 10, 2006 Author Share Posted April 10, 2006 big_daddy, I'm actually already using the WinWait / WinSetState functions as a workaround to my script, but you are absolutely right about WinWaitDelay option, this was the solution for my problem. Not using the WinWaitDelay parameter causes my script to pause 250 ms (the default behaviour) after the window appear. Setting this parameter to 0 causes no delay, so the script now is working flawlessly. Many thanks! Reginald0 Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted April 10, 2006 Moderators Share Posted April 10, 2006 big_daddy, I'm actually already using the WinWait / WinSetState functions as a workaround to my script, but you are absolutely right about WinWaitDelay option, this was the solution for my problem. Not using the WinWaitDelay parameter causes my script to pause 250 ms (the default behaviour) after the window appear. Setting this parameter to 0 causes no delay, so the script now is working flawlessly. Many thanks!Reginald0Glad I was able to help. Link to comment Share on other sites More sharing options...
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