Selenitic Posted March 5, 2008 Posted March 5, 2008 I am trying to search through a computer and find all the locations of notes.ini After I find these ini files I need to remove part of a value in the ini. (I am removing an addin to Lotus Notes) The problem is that I can't simply delete the entire line, because other addins may exist on the computer and every computer could have a different value on that line. This is what I have so far. I appreciate any feedback. Thank you, CODE$var = DriveGetDrive("FIXED") If NOT @error Then For $ii = 1 to $var[0] $a = _FileSearch($var[$ii]&"\","notes.ini",1) If $a[0] > 0 Then For $i = 1 to $a[0] $keyname = "Test" $remove = "2222" $inifile = $a[$i] $sectionname = "Notes" $s = IniRead($inifile, $sectionname, $keyname, "") If StringLen($s) = 0 Then ConsoleWrite("Key not found?" & @CRLF) Exit EndIf ConsoleWrite("$s= " & $s & @CRLF) $rc = StringInStr($s, $remove) ConsoleWrite("$rc= " & $rc & @CRLF) $out = "" If $rc > 0 Then $ss = StringSplit($s, ",") If $ss[0] > 0 Then ; $out = $ss[1] For $i = 1 To $ss[0] $sss = $ss[$i] ConsoleWrite("$ss[" & $i & "]=" & $sss & @CRLF) If StringCompare($remove, $sss) Then ConsoleWrite("Keep " & $sss & @CRLF) If StringLen($out) > 0 Then $out = $out & "," ConsoleWrite("$out = " & $out & @CRLF) EndIf $out = $out & $sss Else ConsoleWrite("Drop " & $sss & @CRLF) EndIf Next ConsoleWrite("String to write is: " & $out & @CRLF) Else ConsoleWrite("No multi-values found?" & @CRLF) EndIf Else ConsoleWrite("String to remove not found?" & @CRLF) EndIf IniDelete($a[$i], "Notes", "Test") IniWrite($a[$i], "Notes", "Test", $out) Next EndIf Next EndIf ;-------------------------------------------- Func _FileSearch($szRoot, $szMask,$nOption) ;$szRoot = "" $hFile = 0 $szBuffer = "" $szReturn = "" $szPathList = "*" Dim $aNULL[1] If $nOption = 0 Then _FileSearchUtil($szRoot, $szMask, $szReturn) Else While 1 $hFile = FileFindFirstFile($szRoot & "*.*") If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @ERROR If $szBuffer <> "." And $szBuffer <> ".." And _ StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _ $szPathList = $szPathList & $szRoot & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) Wend FileClose($hFile) EndIf _FileSearchUtil($szRoot, $szMask, $szReturn) If $szPathList == "*" Then ExitLoop $szPathList = StringTrimLeft($szPathList,1) $szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\" $szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1) Wend EndIf If $szReturn = "" Then $aNULL[0] = 0 Return $aNULL Else Return StringSplit(StringTrimRight($szReturn,1),"*") EndIf EndFunc Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN) $hFile = FileFindFirstFile($ROOT & $MASK) If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @ERROR If $szBuffer <> "." And $szBuffer <> ".." Then _ $RETURN = $RETURN & $ROOT & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) Wend FileClose($hFile) EndIf EndFunc
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