Jump to content

Convert Text to Command?


Recommended Posts

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

Link to comment
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

Link to comment
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)

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...