Systen Automation

Started by stanl, December 28, 2021, 08:31:00 AM

Previous topic - Next topic

stanl


Not sure why this worked; was just playing around


:
Code (WINBATCH) Select
ObjectClrOption ( 'useany', 'System.Management.Automation')
oM = ObjectClrNew('System.Management.Automation.PSObject')
Message("System.Management.Automation.PSObject")




but it raises intersting possibiities...

td

I get a 3074 error - "Expression continues past expected end."
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Me too.   Message only has one parameter.

Jim

stanl

Message("System.Management.Automation.PSObject",OM)

was having a bit of an issue just posting this... like a font fantasy...

JTaylor

Thought that is probably what you meant and had tried it.  I do get an integer....which I assume is the reference for the object.

Jim

td

It is indeed an object reference integer. Since WIL is negatively typed, objects can be represented as a string of digits for display purposes.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Probably just another rabbit hole... and have regularly used System.Management.Automation to run Powershell script code from WB's CLR. I guess just looking if in WB you could assign a file, a process, or something else to a PSObject and work with it without need for external PS code...  [json attached, just rename from .txt to .json]
Code (WINBATCH) Select


json = Dirscript():"assets.json"
If ! FileExist(json) Then Terminate(@TRUE,"File Does Not Exist",json)
ObjectClrOption ( 'useany', 'System.Management.Automation')
oM = ObjectClrNew('System.Management.Automation.PSObject',json)
Message("System.Management.Automation.PSObject",OM)
Members = oM.Members
Props =  oM.Properties
Methods =  oM.Methods
Base =  oM.BaseObject
Message("BaseObject",Base)
Message("Members",Members.ToString())
Message("Properties",Props.ToString())
Message("Methods",Methods.ToString())
oM=0
Exit

td

WinBatch doesn't implement any "special" features for any .Net class so what you see is what you get.

https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.psobject?view=powershellsdk-7.0.0
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on December 31, 2021, 09:48:41 AM
WinBatch doesn't implement any "special" features for any .Net class so what you see is what you get.


rabbitHole = @TRUE