home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / appcreate.vbs < prev    next >
Text File  |  1997-10-25  |  3KB  |  120 lines

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