STD_out for gacutil.exe

Started by spl, February 06, 2026, 11:11:13 AM

Previous topic - Next topic

spl

I know, just another way to iterate .Net assemblies loaded. If you search for gacutil.exe you will probably see multiple files installed. The script below is based on Win10 with .Net 4.8 updated. Be curious as to how it might fail, or how to extract the correct path regardless of Win or .Net version. But, very fast and the PS Out-Gridview is got a lot of features with -PassThru option. You can multiple select, use Ctrl-A or Ctrl-C, filter, sort and use results for multiple purposes. Really no need to even involve WB as could be run as PS from command line. However, if you think about it, the Std_out function could be used for a variety of quick look-sees in OS, SQL Data, or things that just take up too much WB code to replicate.
;Get .NET Assemblies
;Script ends up with a GridView
;Stan Littlefield 2/6/2026
;========================================================================================================================
Gosub udfs
file = Dirscript():"assemblies.txt"
If fileexist(file) Then filedelete(file)

args = $"
$gac = 'C::\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\gacutil.exe'
$assemblies = & $gac /l
$assemblies | Out-Gridview -Title 'GAC Assemblies' -PassThru
$"

cmd="Powershell"
msg='Extended Computer Information'
BoxOpen("Running...",cmd:" ":args:@LF:"PLEASE WAIT...MAY TAKE SOME TIME")
TimeDelay(3)
vals = Get_stdout()
;Message("Net Assemblies - Selected",vals)
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