gentobj.wsc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ' Generating a type library for the specified WSC file.
  2. ' The script assumes to be invoked through a context menu
  3. ' and to receive the WSC name on the command line.
  4. ' ---------------------------------------------------------------
  5. ' Get the WSC file name to work with
  6. If WScript.Arguments.Count = 0 Then
  7. wscFile = InputBox ("Enter the WSC file name:", "WSC")
  8. Else
  9. wscFile = WScript.Arguments.Item(0)
  10. End If
  11. if wscFile = "" Then WScript.Quit
  12. ' Instantiate the object to create the typelib
  13. Set oTL = CreateObject("Scriptlet.TypeLib")
  14. ' Set source and target file names
  15. oTL.AddURL wscFile
  16. tlbFile = Replace(wscFile, ".wsc", ".tlb", 1, -1, 1)
  17. oTL.Path = tlbFile
  18. ' Set the name to appear in the Object Browser
  19. posSlash = InStrRev(wscFile, "\")
  20. posDot = InStrRev(wscFile, ".")
  21. wscFileOnly = Mid(wscFile, posSlash+1, posDot-posSlash-1)
  22. oTL.Name = wscFileOnly & "TLB"
  23. ' Get the description
  24. defDesc = wscFileOnly & " Type Library"
  25. desc = InputBox ("Enter the TypeLib description", "WSC Description", defDesc)
  26. If desc <> "" Then
  27. oTL.Doc = desc
  28. Else
  29. oTL.Doc = defDesc
  30. End If
  31. ' Write the TypeLib
  32. oTL.Write
  33. oTL.Reset