WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

PowerShell
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Class Members From Assembly

 Keywords: Get List Class Members Assembly Name Get-Member Out-Gridview Grid System.Reflection.Assembly LoadwithPartialName System.Management.Automation System.Management.Automation.PowerShell BeginInvoke EndInvoke AddScript

;/////////////////////////////////////////////////////////////////////////////////////////////////////////
;Winbatch 2013A - Get class members from assembly
;                 GridView in Powershell with class as Title
;
;Stan Littlefield, May 7, 2013
;/////////////////////////////////////////////////////////////////////////////////////////////////////////

;generic Powershell Code (should work with both 2.0 and 3.0)
cScript = '[System.Reflection.Assembly]::LoadwithPartialName("|assembly|");':@CRLF 
cScript = cScript:'$obj = New-Object("|class|");':@CRLF
cScript = cScript:'$obj | Get-Member | Out-Gridview -Title "|class|"'

;These are hard-coded here, but could be read from a table or file, or input from prompt
assembly="System.Windows.Forms"
class="System.Windows.Forms.Form"

;simple replacements
cScript=StrReplace(cScript,"|assembly|",assembly)
cScript=StrReplace(cScript,"|class|",class)

ObjectClrOption("use", "System.Management.Automation,version=1.0.0.0,publicKeyToken=31bf3856ad364e35,culture=neutral")
objAutoPs = ObjectClrNew("System.Management.Automation.PowerShell") 
oPshell = objAutoPs.Create()
oScope = ObjectType("BOOL",@TRUE)
oPshell.AddScript(cScript,oScope)
objAsync = oPshell.BeginInvoke() 
oPShell.EndInvoke(objAsync)      

;look for window with class name
WinWaitExist("~":class, 60)
If WinExist("~":class)
   WinActivate("~":class)
   While  WinExist("~":class)
      TimeDelay(1)
   Endwhile
Endif

oPshell.Dispose()
oPshell=0
Exit

Article ID:   W17824
Filename:   Get Class Members From Assembly.txt
File Created: 2013:05:07:11:36:18
Last Updated: 2013:05:07:11:36:18