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.

181 lines
6.5 KiB

  1. '
  2. ' Test IConfigureYourServer::InstallService
  3. '
  4. option explicit
  5. // this is a Visual Basic Script "Template", used in conjunction with the
  6. // MS Visual C++ Preprocessor to overcome some of the source management
  7. // limitations of VBScript. Not perfect, but better than a stick in the eye.
  8. //
  9. // use cl /EP foo.vbt > foo.vbs to expand the template
  10. const SCRIPT_FILENAME = "test-InstallService.vbs"
  11. const SCRIPT_SOURCE_NAME = __FILE__
  12. const SCRIPT_DATE = __DATE__
  13. const SCRIPT_TIME = __TIME__
  14. // this is all our common code.
  15. #include "common.vbi"
  16. Dim QUOTE
  17. QUOTE = Chr(34)
  18. Main
  19. wscript.quit(0)
  20. sub Main
  21. On Error Resume Next
  22. Dim menu(7)
  23. menu(0) = "DNS"
  24. menu(1) = "DHCP"
  25. menu(2) = "DHCPFirstServer"
  26. menu(3) = "WINS"
  27. menu(4) = "IIS - Server "
  28. menu(5) = "StreamingMedia"
  29. menu(6) = "TerminalServices"
  30. menu(7) = "IIS - Adv Server / DTC"
  31. Dim services(7)
  32. services(0) = "DNS"
  33. services(1) = "DHCP"
  34. services(2) = "DHCPFirstServer"
  35. services(3) = "WINS"
  36. services(4) = "IIS"
  37. services(5) = "StreamingMedia"
  38. services(6) = "TerminalServices"
  39. services(7) = "IIS"
  40. Dim i
  41. if wscript.arguments.count <> 1 then
  42. Echo "supply the number of a service to install"
  43. For i = 0 to Ubound(menu)
  44. Echo i & " - " & menu(i)
  45. Next
  46. Exit sub
  47. end if
  48. Dim svcNumber
  49. svcNumber = CInt(wscript.arguments.item(0))
  50. Echo "installing " & services(svcNumber)
  51. Dim srvwiz
  52. Set srvwiz = CreateObject("ServerAdmin.ConfigureYourServer")
  53. if Err.Number then DumpErrAndQuit
  54. ' contents of the inf file
  55. ' use an empty value to mean "use sysoc.inf"
  56. Dim infs(7)
  57. infs(0) = "[Version]" & vbCrLf _
  58. & "Signature = " & QUOTE & "$Windows NT$" & QUOTE & vbCrLf _
  59. & "[Components]" & vbCrLf _
  60. & "NetOC=netoc.dll,NetOcSetupProc,netoc.inf" & vbCrLf _
  61. & "[Global]" & vbCrLf _
  62. & "WindowTitle=Installing DNS Server" & vbCrLf _
  63. & "[Strings]" & vbCrLf _
  64. & ";(empty)" & vbCrLf
  65. infs(1) = "[Version]" & vbCrLf _
  66. & "Signature = " & QUOTE & "$Windows NT$" & QUOTE & vbCrLf _
  67. & "[Components]" & vbCrLf _
  68. & "NetOC=netoc.dll,NetOcSetupProc,netoc.inf" & vbCrLf _
  69. & "[Global]" & vbCrLf _
  70. & "WindowTitle=Installing DHCP Server" & vbCrLf _
  71. & "[Strings]" & vbCrLf _
  72. & ";(empty)" & vbCrLf
  73. infs(2) = infs(1)
  74. infs(3) = "[Version]" & vbCrLf _
  75. & "Signature = " & QUOTE & "$Windows NT$" & QUOTE & vbCrLf _
  76. & "[Components]" & vbCrLf _
  77. & "NetOC=netoc.dll,NetOcSetupProc,netoc.inf" & vbCrLf _
  78. & "[Global]" & vbCrLf _
  79. & "WindowTitle=Installing WINS Server" & vbCrLf _
  80. & "[Strings]" & vbCrLf _
  81. & ";(empty)" & vbCrLf
  82. infs(4) = "" ' use sysoc.inf?
  83. infs(5) = "" ' use sysoc.inf?
  84. infs(6) = "" ' use sysoc.inf
  85. infs(7) = "" ' use sysoc.inf
  86. ' contents of the unattend file
  87. Dim unattends(7)
  88. unattends(0) = "[NetOptionalComponents]" & vbCrLf _
  89. & "DNS=1" & vbCrLf
  90. unattends(1) = "[NetOptionalComponents]" & vbCrLf _
  91. & "DHCPServer=1" & vbCrLf _
  92. & "[dhcpserver]" & vbCrLf _
  93. & "Subnets=10.0.0.0" & vbCrLf _
  94. & "StartIp=10.0.0.3" & vbCrLf _
  95. & "EndIp=10.0.0.254" & vbCrLf _
  96. & "SubnetMask=255.0.0.0" & vbCrLf _
  97. & "LeaseDuration=874800" & vbCrLf _
  98. & "DnsServer=10.10.1.1" & vbCrLf _
  99. & "DomainName=foo.bar.com" & vbCrLf
  100. unattends(2) = unattends(1)
  101. unattends(3) = "[NetOptionalComponents]" & vbCrLf _
  102. & "WINS=1" & vbCrLf
  103. unattends(4) = "[Components]" & vbCrLf _
  104. & "iis_common=ON" & vbCrLf _
  105. & "iis_inetmgr=ON" & vbCrLf _
  106. & "iis_www=ON" & vbCrLf _
  107. & "iis_doc=ON" & vbCrLf _
  108. & "iis_htmla=ON" & vbCrLf _
  109. & "iis_www_vdir_msadc=ON" & vbCrLf _
  110. & "iis_www_vdir_scripts=ON" & vbCrLf _
  111. & "iis_www_vdir_printers=ON" & vbCrLf _
  112. & "iis_smtp=ON" & vbCrLf _
  113. & "iis_smtp_docs=ON" & vbCrLf _
  114. & "fp_extensions=ON" & vbCrLf
  115. unattends(5) = "[Components]" & vbCrLf _
  116. & "WMS=ON" & vbCrLf _
  117. & "WMS_Admin=ON" & vbCrLf _
  118. & "WMS_SERVER=ON" & vbCrLf
  119. ' this is missing the settings for Mode and Permissions
  120. unattends(6) = "[Components]" & vbCrLf _
  121. & "TSEnable=ON" & vbCrLf
  122. unattends(7) = unattends(4)
  123. Dim j
  124. ' For i = 0 to Ubound(services)
  125. i = svcNumber
  126. Err.Clear
  127. Echo "Calling InstallService("
  128. Echo " " & services(i) & ","
  129. Echo " " & infs(i) & ","
  130. Echo " " & unattends(i) & ")"
  131. j = srvWiz.InstallService(services(i), infs(i), unattends(i))
  132. If Err.Number then DumpErrAndQuit
  133. Echo "Installer returned " & j
  134. ' Next
  135. End sub