Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.7 KiB

  1. '''''''''''''''''''''''''''''''''''''''''''''
  2. '
  3. ' Application Creation Utility
  4. '
  5. '''''''''''''''''''''''''''''''''''''''''''''
  6. ' Description:
  7. ' ------------
  8. ' This sample admin script allows you to designate a web directory or virtual directory
  9. ' as an application root.
  10. '
  11. ' To Run:
  12. ' -------
  13. ' This is the format for this script:
  14. '
  15. ' cscript appcreate.vbs <adspath> [-n <friendlyname>][-I (to isolate)]
  16. '
  17. ' NOTE: If you want to execute this script directly from Windows, use
  18. ' 'wscript' instead of 'cscript'.
  19. '
  20. '''''''''''''''''''''''''''''''''''''''''''''
  21. Option Explicit
  22. ' Initialize error checking
  23. On Error Resume Next
  24. ' Initialize variables
  25. Dim ArgCount, TargetNode, InProcFlag, FriendlyName, FlagMsg
  26. Dim DirObj
  27. ' Default values
  28. ArgCount = 0
  29. TargetNode = ""
  30. InProcFlag = True
  31. FriendlyName = "MyNewApp"
  32. ' ** Parse Command Line
  33. ' Loop through arguments
  34. While ArgCount < Wscript.Arguments.Count
  35. ' Determine switches used
  36. Select Case Wscript.Arguments(ArgCount)
  37. Case "-n":
  38. ' Move to next arg, which should be parameter
  39. ArgCount = ArgCount + 1
  40. If ArgCount => Wscript.Arguments.Count Then
  41. Call UsageMsg
  42. Else
  43. FriendlyName = Wscript.Arguments(ArgCount)
  44. End If
  45. Case "-I":
  46. InProcFlag = False
  47. Case "-h", "-?", "/?":
  48. Call UsageMsg
  49. Case Else: ' specifying what ADsPath to look at
  50. If TargetNode <> "" Then ' only one name at a time
  51. Call UsageMsg
  52. Else
  53. TargetNode = Wscript.Arguments(ArgCount)
  54. End If
  55. End Select
  56. ' Move pointer to next argument
  57. ArgCount = ArgCount + 1
  58. Wend
  59. ' Make sure they've specified a path
  60. If TargetNode = "" Then Call UsageMsg
  61. ' Create Application
  62. Set DirObj = GetObject(TargetNode)
  63. If Err.Number <> 0 Then ' Error!
  64. Wscript.Echo "Error: Can't GetObject " & TargetNode & "."
  65. Wscript.Quit(1)
  66. End If
  67. DirObj.AppCreate InProcFlag
  68. If Err.Number <> 0 Then ' Error!
  69. Wscript.Echo "Error: Can't create application for " & TargetNode & "."
  70. Wscript.Quit(1)
  71. End If
  72. ' Set friendly name for application
  73. DirObj.AppFriendlyName = FriendlyName
  74. DirObj.SetInfo
  75. ' Make pretty string
  76. If (InProcFlag = True) Then
  77. FlagMsg = "in-process"
  78. Else
  79. FlagMsg = "isolated"
  80. End If
  81. ' Success!
  82. Wscript.Echo "Created: Application '" & FriendlyName & "' (" & FlagMsg & ")."
  83. ' Displays usage message, then QUITS
  84. Sub UsageMsg
  85. Wscript.Echo "Usage: cscript appcreate.vbs <adspath> [-n <friendlyname>][-I (to isolate)]"
  86. Wscript.Quit
  87. End Sub