Leaked source code of windows server 2003
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.

201 lines
7.9 KiB

  1. 'Copyright (c)<2002>Microsoft Corporation. All rights reserved.
  2. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  3. ' DeleteServices
  4. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  5. Function DeleteServices
  6. On Error Resume Next
  7. Dim WshShell, objEnv, strSADir
  8. Set WshShell = CreateObject("WScript.Shell")
  9. 'Stopping Services
  10. Call WshShell.Run("net stop appmgr", 0, True)
  11. Call WshShell.Run("net stop elementmgr", 0, True)
  12. Call WshShell.Run("net stop srvcsurg", 0, True)
  13. 'Deleting Services
  14. Set objEnv = WshShell.Environment("Process")
  15. strSADir = objEnv("SYSTEMROOT") + "\system32\serverappliance\"
  16. Call WshShell.Run(strSADir & "appmgr.exe -unregserver", 0, True)
  17. Call WshShell.Run(strSADir & "elementmgr.exe -unregserver", 0, True)
  18. Call WshShell.Run(strSADir & "srvcsurg.exe -unregserver", 0, True)
  19. End Function
  20. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  21. ' DeleteLocalUIService
  22. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  23. Function DeleteLocalUIService
  24. On Error Resume Next
  25. Dim WshShell, objEnv, strSADir
  26. Set WshShell = CreateObject("WScript.Shell")
  27. 'Stopping Services
  28. Call WshShell.Run("net stop saldm", 0, True)
  29. 'Deleting Services
  30. Set objEnv = WshShell.Environment("Process")
  31. strSADir = objEnv("SYSTEMROOT") + "\system32\serverappliance\"
  32. Call WshShell.Run(strSADir & "saldm.exe -unregserver", 0, True)
  33. End Function
  34. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  35. ' StartServices
  36. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  37. Function StartServices
  38. On Error Resume Next
  39. Dim objEnv
  40. Dim tmp
  41. Dim WshShell
  42. '
  43. ' registering services here
  44. Set WshShell = CreateObject("WScript.Shell")
  45. set objEnv = WshShell.Environment("Process")
  46. tmp = objEnv("SYSTEMROOT") + "\system32\serverappliance\appmgr.exe -service"
  47. WshShell.Run tmp, 0, TRUE
  48. tmp = objEnv("SYSTEMROOT") + "\system32\serverappliance\appmgr.exe -service"
  49. WshShell.Run tmp, 0, TRUE
  50. tmp = objEnv("SYSTEMROOT") + "\system32\serverappliance\elementmgr.exe"
  51. Set fso = CreateObject("Scripting.FileSystemObject")
  52. If (fso.FileExists(tmp)) Then
  53. tmp = tmp + " -service"
  54. WshShell.Run tmp, 0, TRUE
  55. WshShell.Run tmp, 0, TRUE
  56. End If
  57. tmp = objEnv("SYSTEMROOT") + "\system32\serverappliance\srvcsurg.exe -service"
  58. WshShell.Run tmp, 0, TRUE
  59. tmp = objEnv("SYSTEMROOT") + "\system32\serverappliance\srvcsurg.exe -service"
  60. WshShell.Run tmp, 0, TRUE
  61. tmp = objEnv("SYSTEMROOT") + "\system32\serverappliance\Elementmgr.dll"
  62. WshShell.RegWrite "HKLM\System\CurrentControlSet\Services\Eventlog\Application\Elementmgr\EventMessageFile",tmp
  63. tmp = objEnv("SYSTEMROOT") + "\system32\serverappliance\srvcsurg.dll"
  64. WshShell.RegWrite "HKLM\System\CurrentControlSet\Services\Eventlog\Application\srvcsurg\EventMessageFile",tmp
  65. WshShell.RegWrite "HKLM\System\CurrentControlSet\Services\elementmgr\start",2,"REG_DWORD"
  66. WshShell.RegWrite "HKLM\System\CurrentControlSet\Services\Appmgr\start",2,"REG_DWORD"
  67. WshShell.RegWrite "HKLM\System\CurrentControlSet\Services\Appmgr\TaskCoordinator\RestartableTasks\", ""
  68. WshShell.RegWrite "HKLM\System\CurrentControlSet\Services\srvcsurg\start",2,"REG_DWORD"
  69. 'the services are auto start - so start them now
  70. WshShell.Run "net start winmgmt", 0, TRUE
  71. WshShell.Run "net start appmgr", 0, TRUE
  72. WshShell.Run "net start elementmgr", 0, TRUE
  73. WshShell.Run "net start srvcsurg", 0, TRUE
  74. End Function
  75. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  76. ' StartLocalUIService
  77. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  78. Function StartLocalUIService
  79. On Error Resume Next
  80. Dim objEnv
  81. Dim tmp
  82. Dim WshShell
  83. '
  84. ' registering services here
  85. Set WshShell = CreateObject("WScript.Shell")
  86. set objEnv = WshShell.Environment("Process")
  87. tmp = objEnv("SYSTEMROOT") + "\system32\serverappliance\saldm.exe -service"
  88. WshShell.Run tmp, 0, TRUE
  89. tmp = objEnv("SYSTEMROOT") + "\system32\serverappliance\saldm.exe -service"
  90. WshShell.Run tmp, 0, TRUE
  91. WshShell.Run "net start saldm", 0, TRUE
  92. End Function
  93. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  94. ' StopElementMgr
  95. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  96. Function StopElementMgr
  97. On Error Resume Next
  98. Dim WshShell
  99. Set WshShell = CreateObject("WScript.Shell")
  100. WshShell.Run "net stop winmgmt /y", 0, TRUE
  101. WshShell.Run "net stop appmgr", 0, TRUE
  102. WshShell.Run "net stop srvcsurg", 0, TRUE
  103. WshShell.Run "net stop elementmgr", 0, TRUE
  104. End Function
  105. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  106. ' InitTaskExecutables
  107. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  108. Function InitTaskExecutables
  109. Dim WshShell, dt, bf, te, ae, pa
  110. On Error Resume Next
  111. Set WshShell = CreateObject("WScript.Shell")
  112. bf = WshShell.RegRead("HKLM\System\CurrentControlSet\Services\Appmgr\ObjectName")
  113. 'Remove all occurances of GenTask in case there are more
  114. 'Append GenTask at the end of the key
  115. if bf="LocalSystem" then
  116. 'Check if SetDateTime COM object is installed
  117. dt = WshShell.RegRead("HKLM\Software\Classes\CLSID\{F0229EA0-D1D8-11D2-84FC-0080C7227EA1}\ProgID\")
  118. 'Check if AlertEmail COM object is installed
  119. ae = WshShell.RegRead("HKLM\Software\Classes\CLSID\{44FCEFBB-3477-4FB2-97B0-1651E697A511}\ProgID\")
  120. 'Check if AlertBootTask COM object is installed
  121. pa = WshShell.RegRead("HKLM\SOFTWARE\Classes\CLSID\{90701F02-6539-41F2-973B-ECF2A7439C77}\ProgID\")
  122. 'Check if Self Sign Certificate COM object is installed
  123. ss = WshShell.RegRead("HKLM\SOFTWARE\Classes\CLSID\{EA003ECF-3A51-48DA-86A1-0AFE8C3182AE}\ProgID\")
  124. te = "ServerAppliance.SAGenTask.1 "
  125. 'Persistent alerts need to be the first task on the list, otherwise duplicate alerts get raised
  126. if pa="ServerAppliance.SAAlertBootTask.1" then
  127. te = te + " " + pa
  128. else
  129. te = Replace(te," ServerAppliance.SAAlertBootTask.1","",1,-1,1)
  130. end if
  131. if dt="SetDateTime.DateTime.1" then
  132. te = te + " " + dt
  133. else
  134. te = Replace(te," SetDateTime.DateTime.1","",1,-1,1)
  135. end if
  136. if ae="SetAlertEmail.AlertEmail.1" then
  137. te = te + " " + ae
  138. else
  139. te = Replace(te," SetAlertEmail.AlertEmail.1","",1,-1,1)
  140. end if
  141. if ss="SelfSignCert.SelfSignCert.1" then
  142. te = te + " " + ss
  143. else
  144. te = Replace(te," SelfSignCert.SelfSignCert.1","",1,-1,1)
  145. end if
  146. WshShell.RegWrite "HKLM\Software\Microsoft\ServerAppliance\ApplianceManager\ObjectManagers\Microsoft_SA_Task\ApplianceInitializationTask\TaskExecutables",te
  147. WshShell.RegWrite "HKLM\Software\Microsoft\ServerAppliance\ApplianceManager\ObjectManagers\Microsoft_SA_Task\ApplianceInitializationTask\CanDisable", 0, "REG_DWORD"
  148. WshShell.RegWrite "HKLM\Software\Microsoft\ServerAppliance\ApplianceManager\ObjectManagers\Microsoft_SA_Task\ApplianceInitializationTask\IsEnabled", 1, "REG_DWORD"
  149. WshShell.RegWrite "HKLM\Software\Microsoft\ServerAppliance\ApplianceManager\ObjectManagers\Microsoft_SA_Task\ApplianceInitializationTask\TaskName", "ApplianceInitializationTask"
  150. end if
  151. End Function
  152. Function AddSupportedLanguagesToRegistry
  153. On Error Resume Next
  154. Dim WshShell
  155. Set WshShell = CreateObject("WScript.Shell")
  156. WshShell.Run "regedit /s %SYSTEMROOT%\system32\serverappliance\setup\lang.reg", 0, TRUE
  157. End Function