Jat421 Posted May 29, 2010 Share Posted May 29, 2010 (edited) Hi, Any reason why I can't delete a file with FileDelete() when the path is passed to it from IniRead()? INI file entry [DEL] DEL="@UserProfileDir & "\Desktop\Program.exe"" Code $Del = IniRead("C:\Program\Version.ini", "DEL", "DEL", "") FileDelete($Del) Edited May 29, 2010 by Jat421 Link to comment Share on other sites More sharing options...
Tvern Posted May 29, 2010 Share Posted May 29, 2010 (edited) "@UserProfileDir & "\Desktop\Program.exe"" This is a literal string. The macro is not translated. I'll have a look at a workaround. edit: Remove the outer quotes in your ini file and run this: $PathString = IniRead("C:\Program\Version.ini", "DEL", "DEL", "") ;reads the key $FilePath = Execute($PathString) ;executes the string as if it where code (that's as clear as I can make this sorry) FileDelete($FilePath) ;delete the file Inifile should look like this: [DEL] DEL=@UserProfileDir & "\Desktop\Program.exe" Edited May 29, 2010 by Tvern Link to comment Share on other sites More sharing options...
Developers Jos Posted May 29, 2010 Developers Share Posted May 29, 2010 This will not work because the path string is invalid. The macro @UserProfileDir will not be replaced with the actual value. You have 2 options: 1. check the Opt() parameter: ExpandVarStrings. 2. Form a correct Filedelete() string and use Execute(). Jos 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. Link to comment Share on other sites More sharing options...
Jat421 Posted May 29, 2010 Author Share Posted May 29, 2010 "@UserProfileDir & "\Desktop\Program.exe"" This is a literal string. The macro is not translated. I'll have a look at a workaround. edit: Remove the outer quotes in your ini file and run this: $PathString = IniRead("C:\Program\Version.ini", "DEL", "DEL", "") ;reads the key $FilePath = Execute($PathString) ;executes the string as if it where code (that's as clear as I can make this sorry) FileDelete($FilePath) ;delete the file Inifile should look like this: [DEL] DEL=@UserProfileDir & "\Desktop\Program.exe" That worked like a Charm!!!. Thanks a lot for your help!!!. Still learning from the pros 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