Creating a unique GUID for use in your VBScripts - The VBScript Network and Systems Administrator's Cafe

The VBScript Network and Systems Administrator's Cafe

Feb 13 2009   6:40PM GMT

Creating a unique GUID for use in your VBScripts



Posted by: Jerry Lees
GUID, Scriptlet.TypeLib, VBScipt

Today I answered a question in the ITKE unanswered questions for Word VBA on how to be certain a filename was unique across several users using it. The answer I gave answered the question, but I knew there was a way to create GUID’s within VBScript but couldn’t recall how.

GUID’s are cryptic to look at, but they are pretty much guaranteed to be unique. After some research I found the library that provides this functionality… Scriptlet.TypeLib! Below is a short script that gives you an idea of how to use it in your scripts to generate unique strings for when you need a guaranteed unique name or identifier.

Option Explicit

Dim GUID
Set TypeLib = CreateObject(”Scriptlet.TypeLib”)
GUID = TypeLib.Guid

Enjoy!

Comment on this Post


You must be logged-in to post a comment. Log-in/Register