WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: milesg on June 05, 2020, 05:14:13 AM

Title: UUID
Post by: milesg on June 05, 2020, 05:14:13 AM
How can I generate a UUID in Winbatch?
Title: Re: UUID
Post by: ChuckC on June 05, 2020, 06:49:05 AM
guid1 = ObjectClrNew( 'System.Guid' )

; The class [System.Guid] has a static method, NewGuid(), that generates a random GUID/UUID value.
;  However, I'm not sure how to get WinBatch to execute the static method on the class itself,
;  so we take the class instance in "guid1" and use it to invoke the static method.

newguid = guid1.NewGuid()

Pause( 'GUID', 'newguid = ':newguid.ToString('b') )

Title: Re: UUID
Post by: td on June 05, 2020, 08:51:45 AM
As you have discovered, WIL scopes static members by using "classobject.staticmember" syntax.
Title: Re: UUID
Post by: ChuckC on June 05, 2020, 10:11:39 AM
Noted for future reference.

Title: Re: UUID
Post by: stanl on June 05, 2020, 05:38:52 PM
Quote from: td on June 05, 2020, 08:51:45 AM
As you have discovered, WIL scopes static members by using "classobject.staticmember" syntax.


Not really related but I'm just beginning to learn the use of :: in PS - aha moment, it's a static member as opposed to . which generates an instance



[guid]::NewGuid()