gregor202 Posted April 22, 2009 Share Posted April 22, 2009 I want to open a file (file.link) with another program (the compiled au3 script), just by Drag&Drop it on the *.exe . Then I want to open a configuration file (config.ini) and use the there stored parameters to process with the file.link.So if I drag and drop the file and use the following code:MsgBox(0, "parameter", $CmdLine[1])I get back: "c:/scriptfile/file.link" This is ok.BUT if later in the script, I try to open the configurationfile (config.ini) using the code:$config_file = "config.ini" $program_file = IniRead($config_file, "config", "program", "no_data") MsgBox(0, "file", $program_file)I get back "no_data" , This is NOT OK.> If I don't use Drag&Drop (And define the file.link manually), I get the correct parameter.How do I get it working???Thanks in Advance!Gregor Link to comment Share on other sites More sharing options...
Authenticity Posted April 22, 2009 Share Posted April 22, 2009 Just a side note, you should first check if $CmdLine[0] is greater than 0 or you're going to get a hard crash if you'll try to access a non-existing subscript. ;] The reason why the return value is "no_data" can be a few things. Maybe the file could not be found, the section doesn't exist or the key-name doesn't exist. Don't rely on the current working directory to open a file. Either specify a fixed path like "C:\Temp\config.ini" or if the file should be in the current directory the executable is running from - @ScriptDir & '\config.ini'. Link to comment Share on other sites More sharing options...
ProgAndy Posted April 22, 2009 Share Posted April 22, 2009 I think, the drag-drop changes your workin-dir. Try to soecify a full path for your ini. (@ScriptDir & \config.ini") *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
gregor202 Posted April 22, 2009 Author Share Posted April 22, 2009 Ok, I will test this...Here are the files/code I am using currently:; open with $config_file = "config.ini" ;this was used to create the config file: ;IniWrite($config_file, "config", "program", "c:/test/test.exe") ;to watch the parameter MsgBox(0, "parameter", $CmdLine[1]) $program_file = IniRead($config_file, "config", "program", "no_data") MsgBox(0, "file", $program_file) ;here I everey time get "no_data" but I should get "c:/test/test.exe" MsgBox(0, "file", "finish")config.ini[config] program=c:/test/test.exefile.link[part] identification=21A123 Link to comment Share on other sites More sharing options...
gregor202 Posted April 22, 2009 Author Share Posted April 22, 2009 Yes, he changes the script directory!!! I just changed the code: $config_file = @ScriptDir & "\config.ini" and now it works!!! Thank you a lot for your fast help!!!! 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