home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / free_security / msshared / Shared_Computer_Toolkit_ENU.msi / FileCheckWDP < prev    next >
Encoding:
Text File  |  2005-09-02  |  6.0 KB  |  229 lines

  1. <html>
  2.     <!--
  3.     ' ------------------------------------------------------------------------------
  4.     ' Filename:        CheckWDP.hta
  5.     ' ------------------------------------------------------------------------------
  6.     ' Description:        Runs if Windows Disk Protection is On to show status.
  7.     '             Does not open if Getting Started is set to auto Run.
  8.     ' ------------------------------------------------------------------------------
  9.     ' Version:        1.0
  10.     ' Notes:        
  11.     ' ------------------------------------------------------------------------------
  12.     ' Copyright (C) Microsoft Corporation 2005, All Rights Reserved
  13.     ' ------------------------------------------------------------------------------
  14.     -->
  15.  
  16.     <script id="Common"         language="VBScript" src="include/Common.vbs"></script>
  17.     <script id="libHTA"         language="VBScript" src="include/libHTA.vbs"></script>
  18.     <script id="clsDiskProtect" language="VBScript" src="include/clsDiskProtect.vbs"></script>
  19.  
  20.     <script language="VBScript">
  21.         Option Explicit
  22.         On Error Resume Next
  23.  
  24.         Const GSKEY = "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\SCTRunGettingStarted"            
  25.         ' ~~~ GSKEY = "": Do Not Show Getting Started at Startup, "<hta path/file>": Run Getting Started at Startup
  26.  
  27.         Dim oDiskProtect, sAppDir, iTimer, colProcesses, oProcess, strTemp, iCount, iWDPcmdver, iErr, sAppName
  28.         Dim L_appWidth_Number, L_appHeight_Number
  29.         iErr = 0
  30.         iTimer = 0
  31.         sAppName = "CheckWDP.hta"
  32.  
  33.         ' ~~~ Set the application size and position
  34.         L_appWidth_Number = 280
  35.         L_appHeight_Number = 120
  36.  
  37.         Window.ResizeTo L_appWidth_Number, L_appHeight_Number
  38.         If err.number <> 0 Then iErr = 1
  39.  
  40.         Window.MoveTo Screen.availWidth-(L_appWidth_Number + 20), Screen.availHeight-(L_appHeight_Number+20)
  41.         If err.number <> 0 Then iErr = 1
  42.  
  43.         If iErr = 0 Then
  44.             Setup
  45.         Else
  46.             Window.Close
  47.         End If
  48.  
  49.         ' ~~~
  50.         ' ~~~ Determine if the UI should show at all...
  51.         ' ~~~
  52.         Sub Setup()
  53.             On Error Resume Next
  54.             ' ~~~ Initialize objects
  55.             InitialiseAllObjects()
  56.             'InitialiseAllObjects True
  57.  
  58.             If IsAppRunning Then
  59.                 Window.Close
  60.                 Exit Sub
  61.             End If
  62.  
  63.             ' ~~~ If Getting Started is set to start automatically, close
  64.             If IsNull(RegRead(GSKEY)) and IsAdministrator(True) Then 
  65.  
  66.                     ' ~~~ Set the WDP.CMD tool version number for CheckWDP.hta
  67.                     iWDPcmdVer = 3
  68.                     Set oDiskProtect = New DiskProtect
  69.  
  70.                     ' ~~~ If Disk Protection is not on, close
  71.                     If Not oDiskProtect.Enabled Then 
  72.                         Window.Close
  73.                         Exit Sub
  74.                     End If
  75.             Else
  76.                 Window.Close
  77.                 Exit Sub
  78.             End If
  79.  
  80.         End Sub
  81.  
  82.         ' ~~~
  83.         ' ~~~ Display the Windows Disk Protection Restart Action
  84.         ' ~~~
  85.         Sub WDPAction()
  86.             On Error Resume Next
  87.  
  88.             Set oDiskProtect = Nothing
  89.             Set oDiskProtect = New DiskProtect
  90.  
  91.             ' ~~~ If Disk Protection is not on, quit
  92.             If NOT oDiskProtect.Enabled Then 
  93.                 WDPQuit
  94.             End If
  95.  
  96.             Select Case oDiskProtect.BootCommand
  97.                 Case "SET_LEVEL"
  98.                     spStatus.InnerHTML = resClear.InnerHTML
  99.                 Case "COMMIT"
  100.                     spStatus.InnerHTML = resSave.InnerHTML
  101.                 Case "NO_CMD"
  102.                     If Right(RegRead("HKLM\System\CurrentControlSet\Services\WDPOperations\parameters\Application"),7) = "restore" Then
  103.                         spStatus.InnerHTML = resRetain1.InnerHTML
  104.                     Else
  105.                         spStatus.InnerHTML = resRetain2.InnerHTML
  106.                     End If
  107.                 Case "DISABLE"
  108.                     spStatus.InnerHTML = resOff.InnerHTML
  109.                 Case Else
  110.                     WDPQuit
  111.             End Select
  112.         End Sub
  113.  
  114.         ' ~~~
  115.         ' ~~~ Start a loop to watch Windows Disk Protection status every 20 seconds
  116.         ' ~~~
  117.         Sub WDPChecks()
  118.             On Error Resume Next
  119.             WDPAction
  120.             iTimer = SetInterval("WDPAction", 10000, "VBScript")
  121.         End Sub
  122.  
  123.         ' ~~~
  124.         ' ~~~ Open the Windows Disk Protection tool
  125.         ' ~~~
  126.         Sub WDPQuit()
  127.             On Error Resume Next
  128.             clearInterval iTimer
  129.             Window.Close
  130.             TerminateHTA
  131.         End Sub
  132.  
  133.         ' ~~~
  134.         ' ~~~ Open the Windows Disk Protection tool
  135.         ' ~~~
  136.         Sub OpenWDP()
  137.             On Error Resume Next
  138.             sAppDir = ""
  139.             sAppDir = RegRead(TOOLKITKEY & "TargetDir")
  140.             oShell.Run Chr(34) & sAppDir & "DiskProtect.hta" & Chr(34), 1, True
  141.             WDPAction
  142.         End Sub
  143.  
  144.         Function IsAppRunning()
  145.             IsAppRunning = False
  146.  
  147.             Dim iCount, colProcesses, oProcess
  148.             iCount = 0
  149.         
  150.             Set colProcesses = oWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name='MSHTA.EXE'")
  151.         
  152.             For Each oProcess in colProcesses
  153.                 If Left(Right(LCase(oProcess.CommandLine), len(sAppName) + 2), len(sAppName)) = LCase(sAppName) Then
  154.                     iCount = iCount + 1
  155.                     If iCount > 1 Then
  156.                         IsAppRunning = True
  157.                         Exit Function
  158.                     End If
  159.                 End If
  160.             Next
  161.         End Function
  162.     </Script>
  163.  
  164. <head>
  165. <META http-equiv="Content-Type" content="text/html; charset=utf-8" >
  166.     <title id=Title>Disk Protection Is On</title>
  167.  
  168.     <style type="text/css">
  169.         body
  170.         {
  171.             margin: 0px;
  172.             padding: 4px;
  173.             overflow: hidden;
  174.             font-family: arial;
  175.             font-size: 12px;
  176.         }
  177.  
  178.         p
  179.         {
  180.             margin: 0px;
  181.             padding: 0px;
  182.         }
  183.  
  184.         br
  185.         {
  186.             margin: 0px;
  187.             padding: 0px;
  188.         }
  189.  
  190.         button
  191.         {
  192.             font-size: 12px;
  193.         }
  194.  
  195.     </style>
  196.  
  197.     <hta:application ID="oImagine"
  198.         APPLICATIONNAME="CheckWDP"
  199.         BORDER="Normal"
  200.         CAPTION="Yes"
  201.         ICON="graphics/DiskProtect.ico"
  202.         INNERBORDER="Yes"
  203.         MAXIMIZEBUTTON="no"
  204.         MINIMIZEBUTTON="Yes"
  205.         SCROLL="no"
  206.         SELECTION="no"        
  207.         SHOWINTASKBAR="Yes"
  208.         SINGLEINSTANCE="Yes"
  209.         SYSMENU="Yes"
  210.         VERSION="1.0"
  211.         WINDOWSTATE="normal"/>
  212.  
  213.     <!-- settings and resources -->
  214.     <div id="settings" style="display:none">
  215.         <p id=resClear><b>Clear Changes with each restart</b>.</p>
  216.         <p id=resSave><b>Save Changes with the next restart</b>.</p>
  217.         <p id=resRetain1><b>Retain Changes for one restart</b>.</p>
  218.         <p id=resRetain2><b>Retain Changes</b> indefinitely.</p>
  219.         <p id=resOff><b>Turn Off</b> with the next restart.</p>
  220.     </div>
  221. </head>
  222.  
  223. <body ID=oBody onload="WDPChecks()" onstop="WDPQuit()">
  224.     <p id=pOn>Windows Disk Protection is <b>On</b> and configured to <span id=spStatus></span></p>
  225.     <BR>
  226.     <CENTER><BUTTON ID=btnWDP style="width:80%;" TITLE="Starts the Windows Disk Protection tool" onclick="OpenWDP()">Open Windows Disk Protection</BUTTON></CENTER>
  227. </body>
  228. </html>
  229.