WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stanl on December 28, 2021, 08:31:00 AM

Title: Systen Automation
Post by: stanl on December 28, 2021, 08:31:00 AM

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...
Title: Re: Systen Automation
Post by: td on December 28, 2021, 08:40:30 AM
I get a 3074 error - "Expression continues past expected end."
Title: Re: Systen Automation
Post by: JTaylor on December 28, 2021, 09:01:18 AM
Me too.   Message only has one parameter.

Jim
Title: Re: Systen Automation
Post by: stanl on December 28, 2021, 10:13:25 AM
Message("System.Management.Automation.PSObject",OM)

was having a bit of an issue just posting this... like a font fantasy...
Title: Re: Systen Automation
Post by: JTaylor on December 28, 2021, 01:06:52 PM
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
Title: Re: Systen Automation
Post by: td on December 28, 2021, 03:07:57 PM
It is indeed an object reference integer. Since WIL is negatively typed, objects can be represented as a string of digits for display purposes.
Title: Re: Systen Automation
Post by: stanl on December 31, 2021, 05:54:34 AM
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
Title: Re: Systen Automation
Post by: 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.

https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.psobject?view=powershellsdk-7.0.0 (https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.psobject?view=powershellsdk-7.0.0)
Title: Re: Systen Automation
Post by: stanl on January 01, 2022, 03:31:25 AM
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