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.

266 lines
9.0 KiB

  1. <%@ Language=VbScript%>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' services_noprop.asp : Displays the properties when thers is no specific
  6. ' properties page
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 12-mar-2001 Creation date
  11. ' 15-mar-2001 Modified date
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!-- #include virtual="/admin/inc_framework.asp" -->
  15. <!-- #include file="loc_services.asp" -->
  16. <%
  17. '-------------------------------------------------------------------------
  18. ' Global Variables
  19. '-------------------------------------------------------------------------
  20. 'frame work variables
  21. Dim rc
  22. Dim page
  23. '-------------------------------------------------------------------------
  24. 'Form Variables
  25. '-------------------------------------------------------------------------
  26. Dim F_strServiceSysName 'service name from system- Ex: w3svc
  27. Dim F_strServiceName 'service name - Label
  28. Dim F_strServiceStatus 'service status
  29. Dim F_strStartup 'service startup type
  30. Dim F_strServiceDescription 'service description
  31. Dim F_strTask 'task from query string enable/disable
  32. 'Constants
  33. Const CONST_SERVICES_CONTAINER = "SERVICES"
  34. 'this piece of code is to be placed in init function.
  35. 'for the page title it is moved to here - for localised display name.
  36. F_strServiceSysName = Request.QueryString ("PKey")
  37. 'Get the Service properties - for the page title it is moved to here
  38. getServiceProp(F_strServiceSysName)
  39. ' Create Page
  40. rc = SA_CreatePage( F_strServiceName, "", PT_AREA, page )
  41. ' Show page
  42. rc = SA_ShowPage( page )
  43. '-------------------------------------------------------------------------
  44. 'Function: OnInitPage()
  45. 'Description: Called to signal first time processing for this page.
  46. ' Use this method to do first time initialization tasks
  47. 'Input Variables: PageIn,EventArg
  48. 'Output Variables: PageIn,EventArg
  49. 'Returns: True/False
  50. 'Global Variables: None
  51. '-------------------------------------------------------------------------
  52. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  53. OnInitPage = TRUE
  54. End Function
  55. '---------------------------------------------------------------------
  56. ' Function name: OnServeAreaPage
  57. ' Description: Called when the page needs to be served.
  58. ' Input Variables: PageIn, EventArg
  59. ' Output Variables: PageIn,EventArg
  60. ' Return Values: TRUE to indicate no problems occured. FALSE to indicate errors.
  61. ' Returning FALSE will cause the page to be abandoned.
  62. ' Global Variables: None
  63. 'Called when the page needs to be served. Use this method to serve content.
  64. '---------------------------------------------------------------------
  65. Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  66. Call ServeCommonJavaScript()%>
  67. <TABLE WIDTH=95% BORDER=0 CELLSPACING=0 CELLPADDING=2 style="font-family: Verdana, Arial; font-size:10pt">
  68. <TR>
  69. <TD Class="TasksBody">
  70. <blockquote>
  71. <TABLE WIDTH=100% ALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  72. <TR>
  73. <TD Class="TasksBody"><%=L_SERVICE_NOPROP_PAGE_DESC%>
  74. </TD>
  75. </TR>
  76. <TR>
  77. <TD Class="TasksBody">&nbsp;
  78. </TD>
  79. </TR>
  80. <TR>
  81. <TD>
  82. <blockquote>
  83. <TABLE WIDTH=100% VALIGN=middle ALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  84. <TR>
  85. <TD Class="TasksBody" align='Left' width=15% valign=top><%=L_LABEL_NAME_TEXT%> </TD>
  86. <TD Class="TasksBody" align="left" colspan="2"><%=F_strServiceName%></TD>
  87. </TR>
  88. <TR>
  89. <TD Class="TasksBody" align='Left' width=15% valign=top><%=L_LABEL_DESCRIPTION_TEXT%></TD>
  90. <TD Class="TasksBody" align="left" colspan="2"><%=F_strServiceDescription%></TD>
  91. </TR>
  92. <TR>
  93. <TD Class="TasksBody" align='Left' width=15% valign=top><%=L_LABEL_STATUS_TEXT%> </TD>
  94. <TD Class="TasksBody" align="left" colspan="2"><%=F_strServiceStatus%></TD>
  95. </TR>
  96. <TR>
  97. <TD Class="TasksBody" align='Left' width=15% valign=top><%=L_LABEL_STARTUPTYPE_TEXT%></TD>
  98. <TD Class="TasksBody" align="left" colspan="2"><%=F_strStartup%></TD>
  99. </TR>
  100. </TABLE>
  101. </blockquote>
  102. </TD>
  103. </TR>
  104. </TABLE>
  105. </blockquote>
  106. </TD>
  107. </TR>
  108. </TABLE>
  109. <%
  110. OnServeAreaPage = TRUE
  111. End Function
  112. '---------------------------------------------------------------------
  113. ' Function: ServeCommonJavaScript
  114. ' Description: Serve common javascript that is required for this page type.
  115. ' Input Variables: None
  116. ' Output Variables: None
  117. ' Returns: None
  118. ' Global Variables: None
  119. '---------------------------------------------------------------------
  120. Function ServeCommonJavaScript()
  121. %>
  122. <script>
  123. function Init()
  124. {
  125. return true;
  126. }
  127. </script>
  128. <%
  129. End Function
  130. '---------------------------------------------------------------------
  131. ' SubRoutine: getServiceProp
  132. ' Description: get the service details from the WMI
  133. ' Input Variables: strService - service name
  134. ' Output Variables: None
  135. ' Returns: None
  136. ' Global Variables: F_strServiceName,F_strServiceStatus,F_strStartup
  137. ' F_strServiceDescription
  138. ' form global variables are updated.
  139. '---------------------------------------------------------------------
  140. Sub getServiceProp(strService)
  141. on error resume next
  142. Err.Clear
  143. Dim objWMIService 'getting the wmi service
  144. Dim objServiceName 'gettinmg the service name
  145. Dim strWMIPath 'wmi path
  146. 'constants used for string comparisions.
  147. Const CONST_STOPPED = "stopped"
  148. Const CONST_RUNNING = "running"
  149. Const CONST_PAUSED = "paused"
  150. Const CONST_MANUAL = "manual"
  151. Const CONST_AUTOMATIC = "auto"
  152. Const CONST_DISABLED = "disabled"
  153. 'wmi query string
  154. strWMIPath = "Win32_Service.Name=" & chr(34) & strService & chr(34)
  155. 'connecting to WMI
  156. Set objWMIService = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  157. set objServiceName = objWMIService.get(strWMIPath)
  158. If Err.number <> 0 then
  159. SA_ServeFailurepage L_SERVICE_ACCESS_ERROR & "(" & Err.Number & ")"
  160. Exit Sub
  161. End IF
  162. 'getting the values to form variables
  163. F_strServiceName = objServiceName.Description
  164. F_strServiceStatus = objServiceName.State
  165. F_strStartup = objServiceName.StartMode
  166. 'service status
  167. Select case Ucase(F_strServiceStatus)
  168. Case Ucase(CONST_STOPPED)
  169. F_strServiceStatus = L_STOPPED_TEXT
  170. Case Ucase(CONST_RUNNING)
  171. F_strServiceStatus = L_RUNNING_TEXT
  172. Case Ucase(CONST_PAUSED)
  173. F_strServiceStatus = L_SERVICES_STATUS_PAUSED
  174. End Select
  175. 'service startup type
  176. Select case Ucase(F_strStartup)
  177. Case Ucase(CONST_MANUAL)
  178. F_strStartup = L_MANUAL_TEXT
  179. Case Ucase(CONST_AUTOMATIC)
  180. F_strStartup = L_AUTOMATIC_TEXT
  181. Case Ucase(CONST_DISABLED)
  182. F_strStartup = L_DISABLED_TEXT
  183. End Select
  184. 'clean the objects
  185. objServiceName = nothing
  186. objWMIService = nothing
  187. 'getting the localized service name and desc
  188. Call GetServiceNameAndDescription( strService, F_strServiceName, F_strServiceDescription )
  189. End Sub
  190. '---------------------------------------------------------------------
  191. ' SubRoutine: GetServiceNameAndDescription
  192. ' Description: get the localized service Description from the dll
  193. ' Input Variables: strService - service name
  194. ' strName - Service full name
  195. ' strDesc - service description
  196. ' Output Variables: strName - Service full name
  197. ' strDesc - service description
  198. ' Returns: None
  199. ' Global Variables: None
  200. ' form global variables are updated.
  201. '---------------------------------------------------------------------
  202. Sub GetServiceNameAndDescription(ByVal strService, ByRef strName, ByRef strDesc)
  203. on error resume next
  204. Err.Clear
  205. Dim objElements 'elements from registry
  206. Dim objService 'service object
  207. Const vbTextCompare = 1
  208. 'getting the elements of the serviec container
  209. Set objElements = GetElements(CONST_SERVICES_CONTAINER)
  210. For each objService in objElements
  211. If (StrComp(UCase(strService), UCase(objService.GetProperty("ServiceName")), vbTextCompare)= 0 ) Then
  212. strName = SA_GetLocString(objService.GetProperty("Source"), objService.GetProperty("ServiceNameRID"), "")
  213. If ( Err.Number <> 0 ) Then
  214. SA_TraceErrorOut "SERVICE_NOPROP", "Unable to retrieve ServiceNameRID for service " + strService
  215. SA_SetErrMsg L_FAILEDTOGETSRVOBJ_ERRORMESSAGE
  216. End If
  217. strDesc = SA_GetLocString(objService.GetProperty("Source"), objService.GetProperty("ServiceDescRID"), "")
  218. If ( Err.Number <> 0 ) Then
  219. SA_TraceErrorOut "SERVICE_NOPROP", "Unable to retrieve ServiceDescRID for service " + strService
  220. SA_SetErrMsg L_FAILEDTOGETSRVOBJ_ERRORMESSAGE
  221. End If
  222. Exit For
  223. End If
  224. Next
  225. 'clean the objects
  226. objElements = nothing
  227. End Sub
  228. %>