AnthemCorporation Posted October 10, 2007 Posted October 10, 2007 Hey allI'm trying to get my script to read part of my INI file as a command, so once it's compiled i only need to change the INI file to run it for different programs. is there anyway i can get the script to read the text in my INI file as a command?For example[details]Appname=Testingmessage=This Will Not Reboot... don't stresstitle=Informationcommandline=@windowsdir & "\notepad.exe"restart=nThats the contents of my INI file currently, and yeah, just wanna get that command runningAll help is greatly appreciated
smashly Posted October 10, 2007 Posted October 10, 2007 Hi, I understand this isn't the answer your looking for... Maybe when saving your command to the ini you could use window environment variables saved in your ini instead.. eg: [details] commandline=%SystemRoot%\notepad.exe Then use Opt("ExpandEnvStrings", 1) in your program to read the ini.. eg: Global $Ini = @ScriptDir & "\exenv.ini" Opt("ExpandEnvStrings", 1) $program = IniRead($Ini, "details", "commandline", "") MsgBox(0,'', $program) Cheers
MadBoy Posted October 10, 2007 Posted October 10, 2007 Change commandline in your ini to something like this commandline=@windowsdir\notepad.exe Don't use & or " as this will only complicate things for you. Just use full paths or variables like @windowsdir\notepad.exe @systemdir\notepad.exe .. etc Then this code should do. Make sure to change "C:\mytxt.ini" to @scriptdir & "\yourini.ini" or so. ; Read line from INI $commandline = IniRead("C:\mytxt.ini", "details", "commandline", "") MsgBox(0,1, $commandline) ; Convert any kind of @ variables from autoit (since as you read them from text those are simple text not a variables $commandline = StringReplace($commandline, "@windowsdir", @WindowsDir) MsgBox(0,1, $commandline) ; for any other @windowsdir, @SystemDir etc you gotta do string replace RunWait(@ComSpec & " /c " & $commandline, "", @SW_HIDE) My little company: Evotec (PL version: Evotec)
Moderators SmOke_N Posted October 10, 2007 Moderators Posted October 10, 2007 Change commandline in your ini to something like this commandline=@windowsdir\notepad.exe Don't use & or " as this will only complicate things for you. Just use full paths or variables like @windowsdir\notepad.exe @systemdir\notepad.exe .. etc Then this code should do. Make sure to change "C:\mytxt.ini" to @scriptdir & "\yourini.ini" or so. ; Read line from INI $commandline = IniRead("C:\mytxt.ini", "details", "commandline", "") MsgBox(0,1, $commandline) ; Convert any kind of @ variables from autoit (since as you read them from text those are simple text not a variables $commandline = StringReplace($commandline, "@windowsdir", @WindowsDir) MsgBox(0,1, $commandline) ; for any other @windowsdir, @SystemDir etc you gotta do string replace RunWait(@ComSpec & " /c " & $commandline, "", @SW_HIDE)oÝ÷ ØLZ^jëh×6MsgBox(64, "Info", ExeCute("@WindowsDir")) 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.
smashly Posted October 10, 2007 Posted October 10, 2007 Nice , learn something new every day and moment on these forums. wow so there is a use for Execute , that's one I've never tried... Cheers
MadBoy Posted October 10, 2007 Posted October 10, 2007 MsgBox(64, "Info", ExeCute("@WindowsDir")) Tnx SmOke_N, wasn't aware of that feature. My little company: Evotec (PL version: Evotec)
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