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.

338 lines
21 KiB

  1. ��<HTML>
  2. <!-- Copyright (c) Microsoft Corporation. All rights reserved.-->
  3. <HEAD>
  4. <TITLE>Reboot Page</TITLE>
  5. <SCRIPT LANGUAGE="VBScript">
  6. <!--
  7. Option Explicit
  8. 'Windows constants for key codes
  9. Public Const EnterKey = 13
  10. Public Const EscapeKey = 27
  11. 'Timer for idle timeout
  12. Dim iIdleTimeOut
  13. 'Password reset error text
  14. Dim strRebootErrorText
  15. 'Confirmation text for resetting password
  16. Dim strConfirmRebootText
  17. 'Shutdown text
  18. Dim strShutdownText
  19. 'Flag for status of the page
  20. Dim bRebootingMachine
  21. 'Flag for errors
  22. Dim bInErrorMode
  23. '----------------------------------------------------------------------------
  24. ' Function: Window_OnLoad
  25. ' Description: Initialization routine for the page
  26. ' Input Variables: None
  27. ' Output Variables: None
  28. ' Return Values: None
  29. ' Global Variables: strResetErrorText,strConfirmResetText,bGettingAutoIp
  30. '----------------------------------------------------------------------------
  31. Sub Window_OnLoad()
  32. 'Localization manager object
  33. Dim objLocMgr
  34. 'Replacement strings
  35. Dim varReplacementStrings
  36. 'Resource ID for confirmation for reboot
  37. Const CONFIRM_REBOOT_TEXT = "&H4002000D"
  38. 'Resource ID for reboot error text
  39. Const REBOOT_ERROR_TEXT = "&H4002000E"
  40. 'Resource ID for shutting down text
  41. Const SHUTTINGDOWN_TEXT = "&H40020011"
  42. On Error Resume Next
  43. Err.Clear
  44. bRebootingMachine = false
  45. bInErrorMode = false
  46. 'Create the localization manager
  47. Set objLocMgr = CreateObject("ServerAppliance.LocalizationManager")
  48. If Err.number = 0 Then
  49. 'Get the strings
  50. strRebootErrorText = objLocMgr.GetString("salocaluimsg.dll",REBOOT_ERROR_TEXT,varReplacementStrings)
  51. strConfirmRebootText = objLocMgr.GetString("salocaluimsg.dll",CONFIRM_REBOOT_TEXT,varReplacementStrings)
  52. strShutdownText = objLocMgr.GetString("salocaluimsg.dll",SHUTTINGDOWN_TEXT,varReplacementStrings)
  53. Set objLocMgr = Nothing
  54. End If
  55. Err.Clear
  56. InformationText.innerText = strConfirmRebootText
  57. SaShutdownText.innerText = strShutdownText
  58. ServeLocalUILogo
  59. 'start the timer for idle timeout
  60. iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000)
  61. On Error Resume Next
  62. Err.Clear
  63. 'set the key codes for the page
  64. Dim objKeypad
  65. Set objKeypad = CreateObject("Ldm.SAKeypadController")
  66. If Err.number = 0 Then
  67. objKeypad.Setkey 0,0,TRUE
  68. objKeypad.Setkey 1,0,FALSE
  69. objKeypad.Setkey 2,0,FALSE
  70. objKeypad.Setkey 3,0,FALSE
  71. objKeypad.Setkey 4,EscapeKey,FALSE
  72. objKeypad.Setkey 5,EnterKey,FALSE
  73. Set objKeypad = Nothing
  74. End If
  75. End Sub
  76. '----------------------------------------------------------------------------
  77. ' Function: ServerLocalUILogo
  78. ' Description: Gets the name of the logo file from elementmgr
  79. ' Input Variables: None
  80. ' Output Variables: None
  81. ' Return Values: None
  82. ' Global Variables: salogo
  83. '----------------------------------------------------------------------------
  84. Sub ServerLocalUILogo()
  85. Dim objLogoElementCol
  86. Dim objLogoElement
  87. Dim objRetriever
  88. Dim strLogoFileName
  89. Dim iSmallestMerit
  90. Dim iCurrentMerit
  91. On Error Resume Next
  92. 'Merit for our localui logo
  93. iSmallestMerit = 300
  94. strLogoFileName = ""
  95. 'Create elementmgr and get resource elements
  96. Set objRetriever = CreateObject("Elementmgr.ElementRetriever")
  97. If Err.Number = 0 Then
  98. Set objLogoElementCol = objRetriever.GetElements(1, "OemLocalUILogo")
  99. If Err.Number = 0 Then
  100. 'count the icon and text resources
  101. For Each objLogoElement in objLogoElementCol
  102. iCurrentMerit = CInt(objLogoElement.GetProperty("Merit"))
  103. If iCurrentMerit <= iSmallestMerit Then
  104. iSmallestMerit = iCurrentMerit
  105. strLogoFileName = objLogoElement.GetProperty("ElementGraphic")
  106. End If
  107. Next
  108. End If
  109. End If
  110. Err.Clear
  111. 'Set the logo file
  112. If strLogoFileName <> "" Then
  113. SaLogo.src = strLogoFileName
  114. End If
  115. Set objRetriever = Nothing
  116. Set objLogoElement = Nothing
  117. Set objLogoElementCol = Nothing
  118. End Sub
  119. '----------------------------------------------------------------------------
  120. ' Function: IdleHandler
  121. ' Description: Goes back to main page when timeout expires
  122. ' Input Variables: None
  123. ' Output Variables: None
  124. ' Return Values: None
  125. ' Global Variables: None
  126. '----------------------------------------------------------------------------
  127. Sub IdleHandler()
  128. window.history.go(-2)
  129. End Sub
  130. '----------------------------------------------------------------------------
  131. ' Function: KeyDown
  132. ' Description: Handles key presses
  133. ' Input Variables: None
  134. ' Output Variables: None
  135. ' Return Values: None
  136. ' Global Variables: None
  137. '----------------------------------------------------------------------------
  138. Sub KeyDown()
  139. 'clear the timeout and restart it
  140. window.clearTimeOut(iIdleTimeOut)
  141. iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000)
  142. 'if we are rebooting, ignore all of the keys
  143. If bRebootingMachine = false Then
  144. If bInErrorMode = true Then
  145. 'If we are in error mode, go back to tasks page
  146. If window.event.keycode = EscapeKey or window.event.keycode = EnterKey Then
  147. window.history.go(-1)
  148. End If
  149. Else
  150. 'user wants to reboot the machine
  151. If window.event.keycode = EnterKey Then
  152. bRebootingMachine = true
  153. RebootTheMachine
  154. 'user wants to cancel the operation
  155. ElseIf window.event.keycode = EscapeKey Then
  156. window.history.go(-1)
  157. End If
  158. End If
  159. End If
  160. End Sub
  161. '----------------------------------------------------------------------------
  162. ' Function: RebootTheMachine
  163. ' Description: Reboots the machine
  164. ' Input Variables: None
  165. ' Output Variables: None
  166. ' Return Values: None
  167. ' Global Variables: None
  168. '----------------------------------------------------------------------------
  169. Sub RebootTheMachine
  170. 'TaskContext component
  171. Dim objTaskContext
  172. 'ApplianceServices component
  173. Dim objAS
  174. 'result of the execution
  175. Dim rc
  176. 'SAHelper component
  177. Dim objSAHelper
  178. 'result of privilege operation
  179. Dim bModifiedPrivilege
  180. 'privilege to modify
  181. Const CONST_SHUTDOWNPRIVILEGE = "SeShutdownPrivilege"
  182. bModifiedPrivilege = FALSE
  183. 'shutdown method name
  184. Const strMethodName = "ShutdownAppliance"
  185. 'hide the confirmation text and display the shutdown page
  186. InformationText.style.display = "none"
  187. SaLogo.style.display = ""
  188. SaShutdownText.style.display = ""
  189. SaDownArrow.style.display = ""
  190. On Error Resume Next
  191. Err.Clear
  192. 'Create SAHelper object
  193. Set objSAHelper = CreateObject("ServerAppliance.SAHelper")
  194. If err.number = 0 Then
  195. bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SHUTDOWNPRIVILEGE, TRUE)
  196. End If
  197. bInErrorMode = true
  198. Set objTaskContext = CreateObject("Taskctx.TaskContext")
  199. If Err.Number = 0 Then
  200. Set objAS = CreateObject("Appsrvcs.ApplianceServices")
  201. If Err.Number = 0 Then
  202. 'set the parameters
  203. objTaskContext.SetParameter "Method Name", strMethodName
  204. objTaskContext.SetParameter "SleepDuration", 2000
  205. objTaskContext.SetParameter "PowerOff", "0"
  206. If Err.Number = 0 Then
  207. 'initialize the component
  208. objAS.Initialize()
  209. If Err.Number = 0 Then
  210. bInErrorMode = false
  211. 'execute the task
  212. rc = objAS.ExecuteTaskAsync("ApplianceShutdownTask", objTaskContext)
  213. End If
  214. End If
  215. Set objAS = Nothing
  216. End If
  217. Set objTaskContext = Nothing
  218. End If
  219. 'revert back the privilege
  220. If (bModifiedPrivilege) Then
  221. bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SHUTDOWNPRIVILEGE, FALSE)
  222. End If
  223. Set objSAHelper = Nothing
  224. If bInErrorMode = true Then
  225. bRebootingMachine = false
  226. InformationText.innerText = strRebootErrorText
  227. 'display error text
  228. InformationText.style.display = ""
  229. 'hide the shutdown page
  230. SaLogo.style.display = "none"
  231. SaShutdownText.style.display = "none"
  232. SaDownArrow.style.display = "none"
  233. End If
  234. End Sub
  235. -->
  236. </SCRIPT>
  237. </HEAD>
  238. <BODY RIGHTMARGIN=0 LEFTMARGIN=0 OnKeydown="KeyDown">
  239. <IMG ID="SaLogo" STYLE="position:absolute; top:0; left=0; display:none"
  240. SRC="localui_salogo.bmp" BORDER=0>
  241. <A ID="InformationText" OnKeydown="KeyDown"
  242. STYLE="position:absolute; top:0; left:0; font-size:10; font-family=arial;" >
  243. </A>
  244. <A ID="SaShutdownText" STYLE="position:absolute; top:36; left:0;
  245. font-size:10; font-family=arial; display:none">
  246. </A>
  247. <IMG ID="SaDownArrow" STYLE="position:absolute; top:48; left=0; display:none"
  248. SRC="localui_shutting_down.bmp" BORDER=0>
  249. </BODY>
  250. </HTML>