Sign in to follow this  
Followers 0
AnthemCorporation

Convert Text to Command?

6 posts in this topic

Hey all

I'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=Testing

message=This Will Not Reboot... don't stress

title=Information

commandline=@windowsdir & "\notepad.exe"

restart=n

Thats the contents of my INI file currently, and yeah, just wanna get that command running

All help is greatly appreciated

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

MsgBox(64, "Info", ExeCute("@WindowsDir"))

Tnx SmOke_N, wasn't aware of that feature.


My little company: Evotec (PL version: Evotec)

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