need batch script modified

May 14, 2010 at 21:01:00
Specs: Windows XP
hi can u help me modifiy this script by mikeswim07 i need the script to search all drives
like d e and display all in one txt doc and then give u the option to delete what it found

@echo off
if exist C:\kresults.txt del /q C:\kresults.txt
FOR %%G IN (
abc
123
tree
) DO (
echo Searching for %%G
dir C:\*.* /L /A /B /S|Find "%%G" >> C:\kresults.txt
)
If not exist C:\kresults.txt echo "Files not found" >> C:\kresults.txt
start notepad C:\kresults.txt
exit
--------------------
I also have a vbscript 4 the registry it searchs and deletes but im having trouble modifing it to search 4 multiple keys and it dont display what it found here it is below


Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Const OverwriteIfExist = -1

sStartKeyPath1 = "HKEY_CURRENT_USER"
sStartKeyPath2 = "HKEY_LOCAL_MACHINE"
sStartKeyPath3 = "HKEY_USERS"

sKey = "Yahoo"

Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

' get a temporary registry file name
sTempFile = oFSO.GetSpecialFolder(2).ShortPath & "\" & oFSO.GetTempName

sStart = Now
ExportRegistry sStartKeyPath1, sTempFile
CreateAndRunRegistryFile sKey, sTempFile

ExportRegistry sStartKeyPath2, sTempFile
CreateAndRunRegistryFile sKey, sTempFile

ExportRegistry sStartKeyPath3, sTempFile
CreateAndRunRegistryFile sKey, sTempFile

' delete temp file
If oFSO.FileExists(sTempFile) Then
oFSO.DeleteFile sTempFile
End If

MsgBox "yahoo removed Finished in " & DateDiff("n", sStart, Now) & " minutes", _
vbSystemModal, "findit"

Sub ExportRegistry(sStartKey, sFile)
If Trim(sKey) = "" Then
' export the complete registry
sCmd = "regedit.exe /S /E:A """ & sFile & """"
Else
' export the registry key to a file
sCmd = "regedit.exe /S /E:A """ & sFile & """ " & """" & sStartKey & """"
End If
oShell.Run sCmd, 0, True
End Sub

Sub CreateAndRunRegistryFile(sString, sInFile)


sOutFile = oFSO.GetSpecialFolder(2).ShortPath & "\" & oFSO.GetTempName


' find all string starting with [ and ends with ], and that
' also contains at least one bachslash in addition to the
' text in the variable sString
sCmd = "%comspec% /c findstr.exe " _
& "/i /r ""^\[.*\\.*" & sString & ".*\]$"" """ _
& sInFile & """ >""" & sOutFile & """"


oShell.Run sCmd, 0, True


Set fFile = oFSO.OpenTextFile(sOutFile, ForReading, _
FailIfNotExist, OpenAsASCII)


sResult = ""
On Error Resume Next
sResult = fFile.ReadAll
fFile.Close
oFSO.DeleteFile sOutFile
On Error Goto 0


If sResult <> "" Then


Set fRegFile = oFSO.CreateTextFile(sOutFile, _
OverwriteIfExist, OpenAsASCII)
fRegFile.WriteLine "REGEDIT4" & vbCrLf


aResult = Split(sResult, vbCrLf)


For i = 0 To UBound(aResult)


sLine = aResult(i)


' do the same tests as the regexp in findstr just in case.
If InStr(1, sLine, sString, vbTextCompare) > 0 _
And Left(sLine, 1) = "[" And Right(sLine, 1) = "]" Then


sLine = "[-" & Mid(sLine, 2)
fRegFile.WriteLine sLine
End If
Next


fRegFile.WriteLine vbCrLf ' add two blank lines at the end
fRegFile.Close
sCmd = "regedit.exe /s """ & sOutFile & """"
oShell.Run sCmd, 0, True


End If


If oFSO.FileExists(sOutFile) Then
oFSO.DeleteFile sOutFile
End If

End Sub

----------------------------
i tried sKey = "Yahoo" "yahoo2" etc
and sKey2 = "Yahoo" sKey3 = "Yahoo"
none work it only finds one key at a time


See More: need batch script modified

Report •


#1
May 14, 2010 at 23:01:06
For more and better help you should post this query here:

http://www.computing.net/forum/prog...


Report •
Related Solutions


Ask Question