Why not another STD_Out script

Started by spl, December 05, 2026, 08:12:42 AM

Previous topic - Next topic

spl

I have about 3-4 gig of WB scripts and test files in a \scripts folder with sub-folders, though not very organized. The other day I was thinking about any scripts I had written that tested the CLR PresentationFramework. I know there is a WB search extender but it involves loops for recursion and there was a simple PS one liner. Obviously the code below is specific to that, but anyone interested might want to test with a search. Of course, you can fail the script with looking for 'func' but I would assume you would be more specific, like "adodb.stream" if looking through wb script code. I included my results. Of course, with no reply after 5 days this is gone.
;Quick Text Search with Powershell
;Stan Littlefield 12/4/2026
;NOTE:
;    PS output could be csv, excel, probably Json but not worth the bother
;    folder variable could be just a path w/out a file extension, i.e. E:\scripts\
;    haven't tested that much with spaces between search criteria
;========================================================================================================================
Gosub udfs
file = Dirscript():"search.txt"
If fileexist(file) Then filedelete(file)

folder = "E:\scripts\*.wbt"
srch = "PresentationFramework"
args = "Get-ChildItem -Path [folder] -recurse |  Select-String -Pattern [srch] | Select Path,LineNumber,Line | ft -AutoSize"
args = StrReplace(args,"[folder]",folder)
args = StrReplace(args,"[srch]",srch)

cmd="Powershell"
msg='Search: ':srch
BoxOpen("Running...",cmd:" ":args:@LF:"PLEASE WAIT...MAY TAKE SOME TIME")
TimeDelay(3)
vals = Get_stdout()
Fileput(file,vals)
If FileExist(file) Then Run("notepad.exe",file)
Exit
;======================================================================
:udfs
#DefineSubroutine Get_stdout()
ObjectClrOption("useany","System")
objInfo = ObjectClrNew("System.Diagnostics.ProcessStartInfo")
Output=""
timeOut = ObjectType("I2",5000)
objInfo.FileName = cmd
objInfo.RedirectStandardError = ObjectType("BOOL",@TRUE)
objInfo.RedirectStandardOutput = ObjectType("BOOL",@TRUE)
objInfo.UseShellExecute = ObjectType("BOOL",@FALSE)
objInfo.CreateNoWindow = ObjectType("BOOL",@TRUE)
objInfo.Arguments = args
oProcess = ObjectClrNew("System.Diagnostics.Process")
oProcess.StartInfo = objInfo
BoxShut()
oProcess.Start()
oProcess.WaitForExit(timeout)
STDOUT = oProcess.StandardOutput.ReadToEnd()
STDERR = oProcess.StandardError.ReadToEnd()
Output = Output:STDOUT:@CRLF
;If STDERR<>""
;  Output = Output:"STDERR:":STDERR:@CRLF
;Endif
oProcess = 0
objInfo = 0

Return (Output)
#EndSubroutine
Return
;==========================================================
Stan - formerly stanl [ex-Pundit]

SMF spam blocked by CleanTalk