Launch programs whose path contains spaces

Try:- Dim objShell Set objShell = WScript.CreateObject( “WScript.Shell” ) objShell.Run(“””c:\Program Files\Mozilla Firefox\firefox.exe”””) Set objShell = Nothing Note the extra “”s in the string. Since the path to the exe contains spaces it needs to be contained with in quotes. (In this case simply using “firefox.exe” would work). Also bear in mind that many programs exist … Read more

How to generate a GUID in VBScript?

Function CreateGUID Dim TypeLib Set TypeLib = CreateObject(“Scriptlet.TypeLib”) CreateGUID = Mid(TypeLib.Guid, 2, 36) End Function This function will return a plain GUID, e.g., 47BC69BD-06A5-4617-B730-B644DBCD40A9. If you want a GUID in a registry format, e.g., {47BC69BD-06A5-4617-B730-B644DBCD40A9}, change the function’s last line to CreateGUID = Left(TypeLib.Guid, 38)

Converting string to integer

The function you need is CInt. ie CInt(PrinterLabel) See Type Conversion Functions (Visual Basic) on MSDN Edit: Be aware that CInt and its relatives behave differently in VB.net and VBScript. For example, in VB.net, CInt casts to a 32-bit integer, but in VBScript, CInt casts to a 16-bit integer. Be on the lookout for potential … Read more

ByRef and ByVal in VBScript

Eric Lippert has a great article on using parentheses in VBScript: What do you mean “cannot use parentheses?” Your example illustrates one of the points he mentions, namely: enclosing a ByRef argument in parentheses passes it as ByVal. In short, parentheses in VBScript subroutine calls can be put not only around the argument list, but … Read more

How do I sort arrays using vbscript?

From microsoft Sorting arrays in VBScript has never been easy; that’s because VBScript doesn’t have a sort command of any kind. In turn, that always meant that VBScript scripters were forced to write their own sort routines, be that a bubble sort routine, a heap sort, a quicksort, or some other type of sorting algorithm. … Read more