litlmike Posted October 4, 2007 Posted October 4, 2007 Looking to open an .ini file using AutoIt, just as if I manually double-clicked on the .ini file. So it should open the .ini with the associated program like Notepad. I tried: FileOpen () Execute() Run() TIA _ArrayPermute()_ArrayUnique()Excel.au3 UDF
Moderators SmOke_N Posted October 4, 2007 Moderators Posted October 4, 2007 ShellExecute()This would be my preferred method... but you can also use Run() as you stated above litlmike. $sFile = "C:\TEST.INI" Run(@Comspec & ' /c "' & $sFile & '"', "", @SW_HIDE) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
litlmike Posted October 4, 2007 Author Posted October 4, 2007 Thanks to the both of you. @Smoke Hmmm, not sure why Run did not work when I tried it. I just tried it again, and it still don't work. Wiki: ComSpec (or %COMSPEC%) is one of the environment variables used in MS-DOS and Microsoft Windows, which normally points to the command line interpreter, which is by default command.com or cmd.exe. The ComSpec environment variable by default points to the full path of the command line interpreter. ComSpec is the secondary command line interpreter, which can be anywhere on your system and does not need to be named COMMAND.COM. Still don't know why ComSpec is preferred. Does it have something to do with the File Path? _ArrayPermute()_ArrayUnique()Excel.au3 UDF
Tasmania Posted October 4, 2007 Posted October 4, 2007 (edited) He was actually mentioning that ShellExecute() is his preferred method I believe, however you should be able to use run in the syntax that he had mentioned.No problem, glad I could help Edited October 4, 2007 by Tasmania
Valuater Posted October 4, 2007 Posted October 4, 2007 Run can work... just needs the "start" statement $sFile = "C:\TEST.INI" If FileExists( $sFile) then Run(@ComSpec & " /c Start " & $sFile, "", @SW_HIDE) Else MsgBox(0x0,"error", "file not found ", 3) EndIf 8)
Moderators SmOke_N Posted October 4, 2007 Moderators Posted October 4, 2007 Run can work... just needs the "start" statement $sFile = "C:\TEST.INI" If FileExists( $sFile) then Run(@ComSpec & " /c Start " & $sFile, "", @SW_HIDE) Else MsgBox(0x0,"error", "file not found ", 3) EndIf 8)Hmm, I didn't need the start statement on XP Pro SP2... but I'm sure that is correct all the same. @Tas, yes ... since ShellExecute was added, that has been my preferred method for calling such things like this and or launching website addresses. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Tasmania Posted October 4, 2007 Posted October 4, 2007 Hmm, I didn't need the start statement on XP Pro SP2... but I'm sure that is correct all the same.@Tas, yes ... since ShellExecute was added, that has been my preferred method for calling such things like this and or launching website addresses.Agreed! Since I found out about it, I'm so happy with it
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