keilamym Posted November 29, 2010 Share Posted November 29, 2010 im hoping someone can guide me in the right direction.. i have a tool i created in autoit but portions of the script have hard coded paths. What I'd like to do is move these hard-coded paths to an ini file that the script can simply pull from but im not sure the best method/commands. If has any quick examples or suggestions, please let me know.. i'd really appreciate it. Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 29, 2010 Share Posted November 29, 2010 See IniRead() and IniWrite() in the help file. There are example scripts there. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
keilamym Posted November 29, 2010 Author Share Posted November 29, 2010 See IniRead() and IniWrite() in the help file. There are example scripts there.awesome.. i think i got it figured out.. thanks again... Link to comment Share on other sites More sharing options...
ZacUSNYR Posted November 29, 2010 Share Posted November 29, 2010 Global $inifile = @ScriptDir & "\myinifile.ini" Global $publicnetworkdrive Global $personalnetworkdrive ; Check to see if ini file exists If FileExists($inifile) = 0 Then ; No file exists - so show msgbox and create the ini file MsgBox(0, "Missing INI", "No INI File") CreatePaths() EndIf GetPaths() ; Check INI file for paths If $publicnetworkdrive = "None" or $personalnetworkdrive = "None" Then ;If any keys are missing it'll pickup None ; Display msgbox and recreate file MsgBox(0, "Missing a path in INI", "Missing a path in INI file - recreating") CreatePaths() GetPaths() ; Recheck EndIf ; Display MsgBox with info. MsgBox(0, "Information", $personalnetworkdrive & " is the personal drive" & @CRLF & $publicnetworkdrive & " is the public drive") Func CreatePaths() ; IniWrite used to create the file and add section/keys. IniWrite($inifile, "Paths", "PublicNetworkDrive", "P:\") IniWrite($inifile, "Paths", "PersonalNetworkDrive", "Z:\") EndFunc Func GetPaths() ; IniRead used to read the file. $publicnetworkdrive = IniRead($inifile, "Paths", "PublicNetworkDrive", "None") $personalnetworkdrive = IniRead($inifile, "Paths", "PersonalNetworkDrive", "None") EndFunc IniWrite will create the file and IniRead will auto fill in the variable if it can't read the key. An example is above with limited error control (ie - you could get it to the point where it only creates the keys that are missing, etc). 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