lyledg Posted January 18, 2005 Share Posted January 18, 2005 I am trying to do 2 things here. Code Snippet... $apppath = GuiCtrlCreateInput("", 200, 60, 240, 20) $Regfile = FileOpen(@Scriptdir & "\test.reg", 1) ; Check if file opened for reading OK If $Regfile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit Else 1) Filewriteline($regfile, "[HKEY_LOCAL_MACHINE\SOFTWARE\Installer\Install[Need to put a number here which increments by one each time when this same line is appened to the reg file"] 2) Filewriteline($regfile, '"Command"="' & GUICtrlread($apppath) & '"') In point number 2), This line is going to contain a path, and more likely always from a UNC path which means more than one backslash will appear. But in a exported *.reg file, the path always must have" \\" (2 backslashes) rather than one.. How do I do a search and replace on this line only, replacing the "\" (single backslashes), with double ones "\\" ? I have this line but know it is not right..any help would be appreciated please $File = StringReplace('"Command"="' & GUICtrlread($apppath) & '"', "\", "\\") Thanx Link to comment Share on other sites More sharing options...
Lazycat Posted January 18, 2005 Share Posted January 18, 2005 Why you think that this not right? I'm not see any flaw here. In reg files if you need have backslash, you just escape it by other backslash. So begin of UNC path will looks like "\\\\". Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
jdickens Posted January 18, 2005 Share Posted January 18, 2005 Here is something: If StringInStr("\\", $TestUNCPath) Then ;Done Else StringReplace($TestUNCPath, "\", "\\", 1) EndIf This replaces only the first occurance and only if nec. Did I understand your q? J If I am too verbose, just say so. You don't need to run on and on. Link to comment Share on other sites More sharing options...
lyledg Posted January 18, 2005 Author Share Posted January 18, 2005 Thanks guys for the replies... Lazycat, I think you are right...the writing out of the file should still be ok...I was under the impression that if a exported reg file HAD to have "\\" in any given path statement, but after some more testing I see it should be ok But, any ideas how I could do the following: 1) Filewriteline($regfile, "[HKEY_LOCAL_MACHINE\SOFTWARE\Installer\Install (Need to put a number here which increments by one each time when this same line is appened to the reg file") Example: [HKEY_LOCAL_MACHINE\SOFTWARE\Installer\Install0] [HKEY_LOCAL_MACHINE\SOFTWARE\Installer\Install1] [HKEY_LOCAL_MACHINE\SOFTWARE\Installer\Install2] etc Many thanks Link to comment Share on other sites More sharing options...
Lazycat Posted January 19, 2005 Share Posted January 19, 2005 Hmm, what the "same line" you want to write? This should be exactly "HKEY_LOCAL_MACHINE\SOFTWARE\Installer\Install"? Need a bit more explanation, what the line you will take and how you want to transform it. But anyway, probably you need load all regfile and search for existence of needed line, or use ini read functions. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
jdickens Posted January 19, 2005 Share Posted January 19, 2005 To add the number at the end is easy. Just have a "global" variable initialized to 0 dim $WriteLineCt = 0 which increments each time you go through the write process. $WriteLineCt = $WriteLineCt + 1 And at the end of your string you are trying to write, tack on: StringTrimRight($YourOriginalString, 1) & String($WriteLineCt) & "]" Here is something to keep things neat (Here supporting 99 lines): ;^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v Func Int2_2DigitStr($AnInteger) If $AnInteger < 0 Or ($AnInteger > 99) Then ;Error!! EndIf If $AnInteger < 10 Then Return "0" & String($AnInteger) Else Return String($AnInteger) EndIf EndFunc ;==>Int2_2DigitStr ;^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v J If I am too verbose, just say so. You don't need to run on and on. Link to comment Share on other sites More sharing options...
lyledg Posted January 19, 2005 Author Share Posted January 19, 2005 Thanks JDickens, that is what I was looking for!! Worked a treat! 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