WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: spl on February 27, 2026, 07:38:30 AM

Title: Global Assemblies - just another method
Post by: spl on February 27, 2026, 07:38:30 AM
Below is code using my StdOut() function to display Global assemblies in a PS GridView. Not particularly exciting, but is interesting to see how PS can treat a registry hive as a 'folder' and process it as such, with only 1-2 lines of code. The GridView respects ctrl-A, ctrl-C and multi line selects... and with -Passthru the script could contain additional instructions and still be called for WB. As there is really not much interest in extending WB with PS, I will leave this around over the weekend (see if it gets picked up by AI bots).... then clear code.
;Get .NET Assemblies from Registry Global
;Script ends up with a GridView
;Stan Littlefield 2/27/2026
;========================================================================================================================
Gosub udfs
args = $"if (Get-PSDrive -Name "HKCR" -ErrorAction SilentlyContinue) { Remove-PSDrive -Name "HKCR" }
New-PSDrive -Name HKCR -PSProvider 'Microsoft.PowerShell.Core\Registry' -Root HKEY_CLASSES_ROOT
$gac = Get-ItemProperty -Path 'HKCR::\Installer\Assemblies\Global' | Get-Member -MemberType NoteProperty | Select Name | Out-GridView -Title 'Global .NET Assemblies' -PassThru
$"

cmd="Powershell"
msg='Global Assemblies'
BoxOpen("Running...",cmd:" ":args:@LF:"PLEASE WAIT...MAY TAKE SOME TIME")
TimeDelay(2)
vals = Get_stdout()
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
;==========================================================