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.
 
 
 
 
 
 

340 lines
21 KiB

<HTML>
<!-- Copyright (c) Microsoft Corporation. All rights reserved.-->
<HEAD>
<TITLE>Shutdown Page</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Option Explicit
'Windows constants for key codes
Public Const EnterKey = 13
Public Const EscapeKey = 27
'Timer for idle timeout
Dim iIdleTimeOut
'Password reset error text
Dim strShutdownErrorText
'Confirmation text for resetting password
Dim strConfirmShutdownText
'Shutdown text
Dim strShutdownText
'Flag for status of the page
Dim bShutdowningMachine
'Flag for errors
Dim bInErrorMode
'----------------------------------------------------------------------------
' Function: Window_OnLoad
' Description: Initialization routine for the page
' Input Variables: None
' Output Variables: None
' Return Values: None
' Global Variables: strResetErrorText,strConfirmResetText,bGettingAutoIp
'----------------------------------------------------------------------------
Sub Window_OnLoad()
'Localization manager object
Dim objLocMgr
'Replacement strings
Dim varReplacementStrings
'Resource ID for confirmation for reboot
Const CONFIRM_SHUTDOWN_TEXT = "&H4002000F"
'Resource ID for reboot error text
Const SHUTDOWN_ERROR_TEXT = "&H40020010"
'Resource ID for shutting down text
Const SHUTTINGDOWN_TEXT = "&H40020011"
On Error Resume Next
Err.Clear
bShutdowningMachine = false
bInErrorMode = false
'Create the localization manager
Set objLocMgr = CreateObject("ServerAppliance.LocalizationManager")
If Err.number = 0 Then
'Get the strings
strShutdownErrorText = objLocMgr.GetString("salocaluimsg.dll",SHUTDOWN_ERROR_TEXT,varReplacementStrings)
strConfirmShutdownText = objLocMgr.GetString("salocaluimsg.dll",CONFIRM_SHUTDOWN_TEXT,varReplacementStrings)
strShutdownText = objLocMgr.GetString("salocaluimsg.dll",SHUTTINGDOWN_TEXT,varReplacementStrings)
Set objLocMgr = Nothing
End If
Err.Clear
InformationText.innerText = strConfirmShutdownText
SaShutdownText.innerText = strShutdownText
ServeLocalUILogo
'start the timer for idle timeout
iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000)
On Error Resume Next
Err.Clear
'set the key codes for the page
Dim objKeypad
Set objKeypad = CreateObject("Ldm.SAKeypadController")
If Err.number = 0 Then
objKeypad.Setkey 0,0,TRUE
objKeypad.Setkey 1,0,FALSE
objKeypad.Setkey 2,0,FALSE
objKeypad.Setkey 3,0,FALSE
objKeypad.Setkey 4,EscapeKey,FALSE
objKeypad.Setkey 5,EnterKey,FALSE
Set objKeypad = Nothing
End If
End Sub
'----------------------------------------------------------------------------
' Function: ServerLocalUILogo
' Description: Gets the name of the logo file from elementmgr
' Input Variables: None
' Output Variables: None
' Return Values: None
' Global Variables: salogo
'----------------------------------------------------------------------------
Sub ServerLocalUILogo()
Dim objLogoElementCol
Dim objLogoElement
Dim objRetriever
Dim strLogoFileName
Dim iSmallestMerit
Dim iCurrentMerit
On Error Resume Next
'Merit for our localui logo
iSmallestMerit = 300
strLogoFileName = ""
'Create elementmgr and get resource elements
Set objRetriever = CreateObject("Elementmgr.ElementRetriever")
If Err.Number = 0 Then
Set objLogoElementCol = objRetriever.GetElements(1, "OemLocalUILogo")
If Err.Number = 0 Then
'count the icon and text resources
For Each objLogoElement in objLogoElementCol
iCurrentMerit = CInt(objLogoElement.GetProperty("Merit"))
If iCurrentMerit <= iSmallestMerit Then
iSmallestMerit = iCurrentMerit
strLogoFileName = objLogoElement.GetProperty("ElementGraphic")
End If
Next
End If
End If
Err.Clear
'Set the logo file
If strLogoFileName <> "" Then
SaLogo.src = strLogoFileName
End If
Set objRetriever = Nothing
Set objLogoElement = Nothing
Set objLogoElementCol = Nothing
End Sub
'----------------------------------------------------------------------------
' Function: IdleHandler
' Description: Goes back to main page when timeout expires
' Input Variables: None
' Output Variables: None
' Return Values: None
' Global Variables: None
'----------------------------------------------------------------------------
Sub IdleHandler()
window.history.go(-2)
End Sub
'----------------------------------------------------------------------------
' Function: KeyDown
' Description: Handles key presses
' Input Variables: None
' Output Variables: None
' Return Values: None
' Global Variables: None
'----------------------------------------------------------------------------
Sub KeyDown()
'clear the timeout and restart it
window.clearTimeOut(iIdleTimeOut)
iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000)
'if we are rebooting, ignore all of the keys
If bShutdowningMachine = false Then
If bInErrorMode = true Then
'If we are in error mode, go back to tasks page
If window.event.keycode = EscapeKey or window.event.keycode = EnterKey Then
window.history.go(-1)
End If
Else
'user wants to reboot the machine
If window.event.keycode = EnterKey Then
bShutdowningMachine = true
ShutdownTheMachine
'user wants to cancel the operation
ElseIf window.event.keycode = EscapeKey Then
window.history.go(-1)
End If
End If
End If
End Sub
'----------------------------------------------------------------------------
' Function: ShutdownTheMachine
' Description: Shuts down the machine
' Input Variables: None
' Output Variables: None
' Return Values: None
' Global Variables: None
'----------------------------------------------------------------------------
Sub ShutdownTheMachine
'TaskContext component
Dim objTaskContext
'ApplianceServices component
Dim objAS
'result of the execution
Dim rc
'SAHelper component
Dim objSAHelper
'result of privilege operation
Dim bModifiedPrivilege
'privilege to modify
Const CONST_SHUTDOWNPRIVILEGE = "SeShutdownPrivilege"
bModifiedPrivilege = FALSE
'shutdown method name
Const strMethodName = "ShutdownAppliance"
'hide the confirmation text and display the shutdown page
InformationText.style.display = "none"
SaLogo.style.display = ""
SaShutdownText.style.display = ""
SaDownArrow.style.display = ""
On Error Resume Next
Err.Clear
'Create SAHelper object
Set objSAHelper = CreateObject("ServerAppliance.SAHelper")
If err.number = 0 Then
bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SHUTDOWNPRIVILEGE, TRUE)
End If
bInErrorMode = true
Set objTaskContext = CreateObject("Taskctx.TaskContext")
If Err.Number = 0 Then
Set objAS = CreateObject("Appsrvcs.ApplianceServices")
If Err.Number = 0 Then
'set the parameters
objTaskContext.SetParameter "Method Name", strMethodName
objTaskContext.SetParameter "SleepDuration", 2000
objTaskContext.SetParameter "PowerOff", "1"
If Err.Number = 0 Then
'initialize the component
objAS.Initialize()
If Err.Number = 0 Then
bInErrorMode = false
'execute the task
rc = objAS.ExecuteTaskAsync("ApplianceShutdownTask", objTaskContext)
End If
End If
Set objAS = Nothing
End If
Set objTaskContext = Nothing
End If
'revert back the privilege
If (bModifiedPrivilege) Then
bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SHUTDOWNPRIVILEGE, FALSE)
End If
Set objSAHelper = Nothing
If bInErrorMode = true Then
bShutdowningMachine = false
InformationText.innerText = strShutdownErrorText
'display error text
InformationText.style.display = ""
'hide the shutdown page
SaLogo.style.display = "none"
SaShutdownText.style.display = "none"
SaDownArrow.style.display = "none"
End If
End Sub
-->
</SCRIPT>
</HEAD>
<BODY RIGHTMARGIN=0 LEFTMARGIN=0 OnKeydown="KeyDown">
<IMG ID="SaLogo" STYLE="position:absolute; top:0; left=0; display:none"
SRC="localui_salogo.bmp" BORDER=0>
<A ID="InformationText" OnKeydown="KeyDown"
STYLE="position:absolute; top:0; left:0; font-size:10; font-family=arial;" >
</A>
<A ID="SaShutdownText" STYLE="position:absolute; top:36; left:0;
font-size:10; font-family=arial; display:none">
</A>
<IMG ID="SaDownArrow" STYLE="position:absolute; top:48; left=0; display:none"
SRC="localui_shutting_down.bmp" BORDER=0>
</BODY>
</HTML>