JSchmitt Posted May 2, 2006 Posted May 2, 2006 Hello, I´m reading values from an INI File. I read the value e.g. $var as %WINDIR%\System32\notepad.exe. I can log this variable to a file correctly. If I try to make the following ... Run ($var) I will get an error: Unable to execute the external program. This is just an example ... i would like to call another program defined in an INI File using environment variables! Does anyone has an idea. Thx in advance.
Developers Jos Posted May 2, 2006 Developers Posted May 2, 2006 (edited) JSchmitt said: Hello, I´m reading values from an INI File. I read the value e.g. $var as %WINDIR%\System32\notepad.exe. I can log this variable to a file correctly. If I try to make the following ... Run ($var) I will get an error: Unable to execute the external program. This is just an example ... i would like to call another program defined in an INI File using environment variables! Does anyone has an idea. Thx in advance.try : Run(@comspec & " /c " & $var,"",@SW_HIDE) Or: Opt("ExpandEnvStrings", 1) Run ($var) Edited May 2, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
JSchmitt Posted May 2, 2006 Author Posted May 2, 2006 Hello, I have the OPT set and I tried your advice with no improvement. I can call %TEMP% Variables set to Variables like: $Execute = %Temp%\Hello.exe but I can´t RUN a Command including variables read from an INI File!?
Danny35d Posted May 2, 2006 Posted May 2, 2006 May be if you post your script or part of your script and example of what the ini file look like. I'm sure somebody will be able to help you. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
JSchmitt Posted May 3, 2006 Author Posted May 3, 2006 Hello, here an example for my problem. calc.exe will start. notepad.exe will not start with the above mentioned error. Does anyone knows what the problem is? Thx in advance Jochen [AUT FILE] Opt("ExpandEnvStrings", 1) If $CmdLine[0] = 0 Then If FileExists(@ScriptDir & "\Test.ini") Then $ConfigFile=@ScriptDir & "\Test.ini" Else Exit EndIf Else $ConfigFile=$CmdLine[1] EndIf $Path = IniRead($ConfigFile, "Settings", "Path", "%WINDIR%\SYSTEM32") $strExecute="%WINDIR%\SYSTEM32\CALC.EXE" Run ($strExecute) $strExecute=$Path & "\NOTEPAD.EXE" Run ($strExecute, $Path) [TEST.INI FILE] [settings] Path=%WINDIR%\System32
Valuater Posted May 3, 2006 Posted May 3, 2006 i just tested the last posted code... and it worked fine both calc & notepad showed 8)
JSchmitt Posted May 3, 2006 Author Posted May 3, 2006 Hello, I tried it on windows xp german and windows 2003 english with autoit3.exe version 3.1.1.0 downloaded yesterday and it won´t work !? Can anyone else test the script and report the result. With OS Version and AutoIT3 Version. Thanx Jochen
MHz Posted May 3, 2006 Posted May 3, 2006 (edited) Your test is confirmed as an issue with AutoIt v3.1.1 release.AutoIt v3.1.1 will only expand literal Environmental Strings.e.g.MsgBox(0, '3.1.1', '%WINDIR%')AutoIt Beta had changes made to convert Environmental Strings within a variable also.MsgBox(0, 'Beta', '%WINDIR%') $Var = %WINDIR% MsgBox(0, 'Beta', $Var)Your issue was mentioned back in time here.If you want to use the option of ExpandEnvStrings, I would recommend to use the beta here.Edit:The last code shows as literal as well, but consider it as an INIRead or RegRead into a variable instead which would not be a literal string within the script itself. The later will only work correctly in the beta. Edited May 3, 2006 by MHz
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