News:

Current release: WB 2024B (6.24bxb)

Main Menu

UUID

Started by milesg, June 05, 2020, 05:14:13 AM

Previous topic - Next topic

milesg

How can I generate a UUID in Winbatch?

ChuckC

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') )


td

As you have discovered, WIL scopes static members by using "classobject.staticmember" syntax.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

ChuckC

Noted for future reference.


stanl

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()