Sign in to follow this  
Followers 0
litlmike

Opening an .ini File

8 posts in this topic

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

Share this post


Link to post
Share on other sites



ShellExecute()

Share this post


Link to post
Share on other sites

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)

[center]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.[/center]

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Tasmania

Share this post


Link to post
Share on other sites

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.


[center]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.[/center]

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0