Re: Script to find a string in a text file on a remote computer by RemS
RemS
Wed Jun 20 05:31:02 CDT 2007
"S Moran" wrote:
> you should get intt the habit of using "&" to concat in vbscript as opposed
> to "+"
Luckyly notepad has a Find&Replace function then.
My habit btw IS using & and not +
:)
airwot4 ,
Note that the script is expanding the %AllUsersProfile% variable from *your*
computer - Not from the environment on the remote computer!
It uses that same path to browse on the target computer. So the script
assumes the "All Users" folder is on the same path on both computers.
If not, then manually provide the correct path for the target computer
(using the administrative share to access the target computer).
grtz,
> "\RemS" <RemS@discussions.microsoft.com> wrote in message
> news:5C191189-1A32-4954-8D6C-C25C2413FC7B@microsoft.com...
> > "airwot4" wrote:
> >> Could anybody help with me a script that is able to open a text file
> >> on a remote computer, search it for a specified string, and then
> >> return to me that string AND the line below it (or the next 30
> >> characters).
> >>
> >> I'm hoping to query a number of machine's drwtsn32.log files to find
> >> similer errors.
> >>
> >> The string I want to search for is "App: C:\Program Files\Internet
> >> Explorer\iexplore.exe." and the line below it would be something like
> >> "When: 10/05/2006 @ 11:01:24.511."
> >>
> >> So basically I'm trying to find out when these errors are occurring.
> >>
> >
> > Here is a start:
> >
> >
> > strComputer = "targetcomputername"
> >
> > Set objShell = Wscript.CreateObject("Wscript.shell")
> > strDrwtsnLog = "drwtsn32.log"
> > strDrwtsnpath = objShell.ExpandEnvironmentStrings _
> > ("%AllUsersProfile%\Application Data\Microsoft\Dr Watson")
> > strDrwtsnpath = """\\"+strComputer+"\"+Replace(strDrwtsnpath, _
> > ":\","$\")+"\"+strDrwtsnLog+""""
> >
> > Set execObj= objShell.Exec("cmd /c type "+strDrwtsnpath)
> >
> > Do While Not execObj.StdOut.AtEndOfStream
> > strVar = execObj.StdOut.ReadLine
> > If incNextLine = "YES" then
> > strString2 = strVar
> > incNextLine = vbNullString
> > ElseIf Instr(strVar,"App: C:\Program Files\Internet Explorer" & _
> > "\iexplore.exe (pid=") then
> > strString1 = strVar
> > incNextLine = "YES"
> > Else incNextLine = vbNullString
> > End If
> > Loop
> >
> > msgBox(strComputer+vbNewLine+strString1+vbNewLine+strString2)
> >
> >
> >
> > \RemS