home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / free_security / msshared / Shared_Computer_Toolkit_ENU.msi / FileInclude015 < prev    next >
Encoding:
Text (UTF-16)  |  2005-09-02  |  113.7 KB  |  1,512 lines

  1. ' ***
  2. ' *** --------------------------------------------------------------------------
  3. ' *** Filename:        Restrictions.vbs
  4. ' *** --------------------------------------------------------------------------
  5. ' *** Description:    Code for the User Restrictions HTA
  6. ' *** --------------------------------------------------------------------------
  7. ' *** Version:        1.0
  8. ' *** Notes:        
  9. ' *** --------------------------------------------------------------------------
  10. ' *** Copyright (C) Microsoft Corporation 2005, All Rights Reserved
  11. ' *** --------------------------------------------------------------------------
  12. ' ***
  13.  
  14. ' ~~~ 
  15. ' ~~~ Force variables to be declared and turn off script error messages unless in DEBUG mode
  16. ' ~~~ 
  17. Option Explicit
  18. If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  19.  
  20. ' ~~~ 
  21. ' ~~~ Declare global variables
  22. ' ~~~ 
  23. Dim oRestriction, oLog, oLockPopup, oRestrictPopup, oLockAgainPopup, iUserMessages, bLockError
  24. Dim bShowLockPopup, bShowResPopup, bShowPopup, bUserMessages, bLockAgainPopup 
  25. Dim sAccountName ' Stores the user account name to be restricted
  26. Dim bFAT32Drive, sCurrentScrSvr
  27.  
  28. ' ***
  29. ' *** ------------------------------------------------------------------------------
  30. ' *** Name:            Init()
  31. ' *** ------------------------------------------------------------------------------
  32. ' *** Purpose:        Initialises all the variables and gets the xml template
  33. ' *** ------------------------------------------------------------------------------
  34. ' ***
  35. Sub Init()
  36.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  37.     Dim sRootFolder
  38.     
  39.     ' ~~~ Global variable that stores the current screen saver set for the local user
  40.     sCurrentScrSvr = ""     
  41.  
  42.     ' ~~~ Create objects
  43.     Set oRestriction = New Restriction
  44.     Set oLog         = New Logging
  45.     sRootFolder       = GetRootFolder
  46.  
  47.     ' ~~~ Initiate logging & bind the logging object to the restrictions object
  48.     Call oLog.Open(sRootFolder & "\log\Restrict.hta.log")
  49.     Call oLog.Write("Restrict.hta : Started")
  50.     oRestriction.Logging = oLog
  51.  
  52.     ' ~~~ Set the template file
  53.     oRestriction.TemplateXML = sRootFolder & "\xml\" & GetAppname & ".xml"
  54.  
  55.     ' ~~~ Delete all the old User xml files
  56.     On Error Resume Next
  57.     Call oFSo.DeleteFile(sRootFolder & "\xml\User.*.xml", True)
  58.  
  59.     ' ~~~ If error, key does not exist, value=off
  60.     If err.number <> 0 Then
  61.         err.Clear
  62.     End If
  63.  
  64.     ' ~~~ Turn off error handling
  65.     On Error Goto 0
  66.     
  67.     ' ~~~ Populate restrictions
  68.     Call AddRestrictions()
  69.     
  70.     ' ~~~ Create the popup's
  71.     Set oLockPopup = Window.createpopup()
  72.     Set oRestrictPopup = Window.createpopup()
  73.     Set oLockAgainPopup = Window.createpopup()
  74. End Sub
  75.  
  76. ' ***
  77. ' *** ------------------------------------------------------------------------------
  78. ' *** Name:            Load()
  79. ' *** ------------------------------------------------------------------------------
  80. ' *** Purpose:        This subroutine is executed before a wizard page is displayed
  81. ' *** ------------------------------------------------------------------------------
  82. ' ***
  83. Sub Load()
  84.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  85.     
  86.     ' ~~~ Call the sub to enable body 
  87.     Call BodyDisable(False) 
  88.     
  89.     ' ~~~ Call the method to write the user session in registry
  90.     Call UserSessionReg(oNetwork.UserName)
  91.     
  92.     ' ~~~ Set tooltip messages
  93. '    btnAccessDisks.title = resPreventDisks.innerHTML 
  94.     spchkSharedAccount.Title = resLockProfileTooltip.innerText 
  95.     chkSharedAccount.Title = resLockProfileTooltip.innerText 
  96.     
  97.     txtAccessDisks.style.visibility = "visible"
  98.     txtAccount.value = ""
  99.     txtAccount.ReadOnly = True
  100.  
  101.     ' ~~~ To make the default selection to selectprofile button
  102.     btnSelectProfile.SetActive()
  103.     btnApply.disabled = True
  104.     DisableAllControls(True)
  105.  
  106.     bShowPopup = False
  107.     bShowLockPopup = True
  108.     bShowResPopup = True
  109.     bLockAgainPopup = True
  110. End Sub
  111.  
  112. ' ***
  113. ' *** ------------------------------------------------------------------------------
  114. ' *** Name:            Validate()
  115. ' *** ------------------------------------------------------------------------------
  116. ' *** Purpose:        This function is executed before a wizard page is exited
  117. ' ***                If this function returns false. The page does not exit.
  118. ' *** ------------------------------------------------------------------------------
  119. ' ***
  120. Function Validate()
  121.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  122.     Validate = True
  123. End Function
  124.  
  125. ' ***
  126. ' *** ------------------------------------------------------------------------------
  127. ' *** Name:            Action()
  128. ' *** ------------------------------------------------------------------------------
  129. ' *** Purpose:        This subroutine performs the actual functionality of the tool
  130. ' *** ------------------------------------------------------------------------------
  131. ' ***
  132. Sub Action()
  133.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  134.     
  135.     ' ~~~ If already applied ; no need to apply through OK
  136.     If btnApply.disabled = False Then
  137.         Call Apply()
  138.     End If 
  139. End Sub
  140.  
  141. ' ***
  142. ' *** ------------------------------------------------------------------------------
  143. ' *** Name:            AddRestrictions()
  144. ' *** ------------------------------------------------------------------------------
  145. ' *** Purpose:        Adds all of the check boxes to the restrictions section
  146. ' *** ------------------------------------------------------------------------------
  147. ' ***
  148. Sub AddRestrictions()
  149.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  150.     
  151.     Dim oDIV, oXML, oSection, oNode, sHTML, oOptDiv
  152.  
  153.     ' ~~~ Get the div, xml template file and the restrictions section
  154.     Set oDIV = divRestrictions
  155.     Set oXML = oRestriction.OpenXMLFile(oRestriction.TemplateXML)
  156.  
  157.     ' ~~~ Cycle through sections
  158.     For Each oSection In oXML.selectNodes("/restrictions/allrestrictions/section[@type=""allrestrictions""]")
  159.         ' ~~~ Add the div for this section
  160.         sHTML = ""
  161.         sHTML = sHTML & "<ssw:checkbox id=""chk" & oSection.Attributes.GetNamedItem("id").Text & """ tabindex = 0 onResultChange=""Bubble(this)"" /> "
  162.         sHTML = sHTML & "<img id=""img" & oSection.Attributes.GetNamedItem("id").Text  &  """ src=""graphics/tickit.gif"" alt=""+"" title="""" align=""absmiddle"" onclick=""ShowHideSection('" & oSection.Attributes.GetNamedItem("id").Text & "')""> "
  163.         sHTML = sHTML & "<span class=restrict id=""sp" & oSection.Attributes.GetNamedItem("id").Text  &"""style=""cursor:hand"" onclick=""ShowHideSection('" & oSection.Attributes.GetNamedItem("id").Text & "')"">" & oSection.Attributes.GetNamedItem("name").Text & "</span><br>" & vbCrLf
  164.         sHTML = sHTML & "<DIV id=""div" & oSection.Attributes.GetNamedItem("id").Text & """ style=""display:none; padding-left:42px"">" & vbCrLf
  165.  
  166.         ' ~~~ Add children to the div
  167.         For Each oNode In oSection.childNodes
  168.             sHTML = sHTML & "<table cellpadding=""0"" cellspacing=""1"" border=""0"">"
  169.             sHTML = sHTML & "<tr valign=""top"">"
  170.             sHTML = sHTML & "<td><ssw:checkbox id=""" & oNode.Attributes.GetNamedItem("id").Text & """ tabindex = 0 onResultChange=""Bubble(this)"" /> </td>"
  171.             sHTML = sHTML & "<td><span class=restrict id=""" & "sp" & oNode.Attributes.GetNamedItem("id").Text  & """ onClick=""Bubble(window.event.srcelement)"">" & oNode.Attributes.GetNamedItem("name").Text &  "</span></td>" & vbCrLf
  172.             sHTML = sHTML & "</tr></table>"
  173.         Next
  174.         
  175.         ' ~~~ Close section div and add it to the document
  176.         sHTML = sHTML & "</DIV>" & vbCrLf
  177.         oDIV.innerHTML = oDIV.innerHTML & sHTML
  178.     Next
  179.     Set oDIV = Nothing
  180.     
  181.     ' ~~~ Optional restrictions 
  182.     Set oOptDiv =  divOptRestrictions
  183.     For Each oSection In oXML.selectNodes("/restrictions/optionalrestrictions/section[@type=""optionalrestrictions""]")
  184.         ' ~~~ Add the div for this section
  185.         sHTML = ""
  186.         sHTML = sHTML & "<input type=""image"" id=""img" & oSection.Attributes.GetNamedItem("id").Text  &  """ src=""graphics/tickit.gif"" alt=""+"" title="""" align=""absmiddle"" onclick=""ShowHideSection('" & oSection.Attributes.GetNamedItem("id").Text & "')"" > "
  187.         sHTML = sHTML & "<span class=restrict id=""sp" & oSection.Attributes.GetNamedItem("id").Text  &""" style=""cursor:hand"" onclick=""ShowHideSection('" & oSection.Attributes.GetNamedItem("id").Text & "')"">" & oSection.Attributes.GetNamedItem("name").Text & "</span><br>" & vbCrLf
  188.         sHTML = sHTML & "<div id=""div" & oSection.Attributes.GetNamedItem("id").Text & """ style=""display:none; padding-left:42px"">" & vbCrLf
  189.  
  190.         ' ~~~ Add children to the div
  191.         For Each oNode In oSection.childNodes
  192.             sHTML = sHTML & "<table cellpadding=""0"" cellspacing=""0"" border=""0"">"
  193.             sHTML = sHTML & "<tr>"
  194.             If oNode.Attributes.GetNamedItem("id").Text = "chkDisableInternet" Then
  195.                 sHTML = sHTML & "<td valign=""top""><input type=""checkbox"" id=""" & oNode.Attributes.GetNamedItem("id").Text & """ tabindex = 0 onclick=""ChangeDisableInternet()"" > </td>"
  196.             Else
  197.                 sHTML = sHTML & "<td valign=""top""><input type=""checkbox"" id=""" & oNode.Attributes.GetNamedItem("id").Text & """ tabindex = 0 onclick=""OptRestrictionsClick('" & oNode.Attributes.GetNamedItem("id").Text & "')"" > </td>"
  198.             End If            
  199.             sHTML = sHTML & "<td valign=""middle""><span class=restrict id=""sp" & oNode.Attributes.GetNamedItem("id").Text  & """ onclick=""OptRestrictionsClick('sp" & oNode.Attributes.GetNamedItem("id").Text & "')"" >" & oNode.Attributes.GetNamedItem("name").Text &  "</span></td>" & vbCrLf
  200.             sHTML = sHTML & "</tr></table>"
  201.         Next
  202.  
  203.         ' ~~~ Close section div and add it to the document
  204.         sHTML = sHTML & "</div>" & vbCrLf
  205.         oOptDiv.innerHTML = oOptDiv.innerHTML & sHTML
  206.     Next
  207. End Sub
  208.  
  209. ' ***
  210. ' *** ------------------------------------------------------------------------------
  211. ' *** Name:            ChangeUser()
  212. ' *** ------------------------------------------------------------------------------
  213. ' *** Purpose:        Loads user data when the user is selected
  214. ' *** ------------------------------------------------------------------------------
  215. ' ***
  216. Sub ChangeUser()
  217.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  218.     
  219.     ' ~~~ Now load the new user, unless blank was selected
  220.     If document.all("txtAccount").value <> "" Then
  221.          
  222.         Call LoadUser()
  223.         
  224.         ' ~~~ To call the method to show popup
  225.         bShowLockPopup = True
  226.         bShowResPopup = True
  227.         bLockAgainPopup = True
  228.  
  229.         ' ~~~ Method to check the file system of the profile location
  230.         ' ~~~ and disable "Lock Profile"
  231.         Call CheckFilesystem()
  232.         
  233.         ' ~~~ Pop up baloons are displayed based on the user's settings.
  234.         Call ShowHidePopup()
  235.         
  236.     End If
  237. End Sub
  238.  
  239. ' ***
  240. ' *** ------------------------------------------------------------------------------
  241. ' *** Name:            LoadUser()
  242. ' *** ------------------------------------------------------------------------------
  243. ' *** Purpose:        Creates xml for the user and populates the UI
  244. ' *** ------------------------------------------------------------------------------
  245. ' ***
  246. Sub LoadUser()
  247.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  248.     
  249.     Dim oXML, bOK, oChild, iValue
  250.  
  251.     ' ~~~ Turn on error handling
  252.     On Error Resume Next
  253.  
  254.     ' ~~~ Default to true for users we do not need to create
  255.     bOK = True
  256.  
  257.     ' ~~~ Set the user and create its xml file, if it does not already exist
  258.     oRestriction.User = sAccountName
  259.  
  260.     ' ~~~ Always load the profile settings from Registry not from the existing xml file    
  261.     bOK = oRestriction.CreateXML
  262.  
  263.     ' ~~~ If xml file created ok, or already exists!
  264.     If bOK Then
  265.         ' ~~~ Open xml file
  266.         Set oXML = oRestriction.OpenXMLFile(oRestriction.UserXML)
  267.  
  268.         ' ~~~ Set the check boxes of the sections
  269.         Call LoadSection(oXML, "general")
  270.         Call LoadSection(oXML, "allrestrictions")
  271.         Call LoadSection(oXML, "optionalrestrictions")
  272.         
  273.         ' ~~~ Set state if disable internet access check box
  274.         If txtProxy.Value = "NoInternetAccess" Then
  275.             chkDisableInternet.Checked = True
  276.         Else
  277.             chkDisableInternet.Checked = False
  278.         End If
  279.  
  280.         ' ~~~ Now we need to set the state of "All Restrictions"
  281.         iValue = -1
  282.         For Each oChild in divRestrictions.getElementsByTagName("checkbox")
  283.             iValue = GetChildValue(iValue, oChild.value)
  284.         Next
  285.         chkRestrictions.value = iValue
  286.         chkRestrictions.save
  287.  
  288.         ' ~~~ Destroy xml objects
  289.         Set oXML = Nothing
  290.  
  291.         ' ~~~ Check if disable internet was checked
  292.         ChangeDisableInternetLoad()
  293.     Else
  294.         ' ~~~ Display error message
  295.         Call MsgBox(document.all("resErrorLoadingUser").innerHTML, vbOKOnly + vbCritical, L_sToolkitTitle_TEXT)
  296.         txtAccount.value = ""
  297.     End If
  298.  
  299. End Sub
  300.  
  301. ' ***
  302. ' *** ------------------------------------------------------------------------------
  303. ' *** Name:            SaveUser()
  304. ' *** ------------------------------------------------------------------------------
  305. ' *** Purpose:        Saves a users settings
  306. ' *** ------------------------------------------------------------------------------
  307. ' ***
  308. Sub SaveUser()
  309.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  310.  
  311.     ' ~~~ Turn on error handling
  312.     On Error Resume Next
  313.  
  314.     Dim oXML
  315.     ' ~~~ Set the user and create its xml file, if it does not already exist
  316.     oRestriction.User = sAccountName
  317.     
  318.     If Not(oFso.FileExists(oRestriction.UserXML)) Then
  319.         bOK = oRestriction.CreateXML
  320.     End If
  321.     
  322.     ' ~~~ Open users XML file and get the pokes
  323.     Set oXML = oRestriction.OpenXMLFile(oRestriction.UserXML)
  324.  
  325.     ' ~~~ Save the check boxes of the sections
  326.     Call SaveSection(oXML, "general")
  327.     Call SaveSection(oXML, "allrestrictions")
  328.     Call SaveSection(oXML, "optionalrestrictions")
  329.  
  330.     ' ~~~ Save the xml file
  331.     Call oXML.Save(oRestriction.UserXML)
  332.     
  333.     ' ~~~ Clear the user
  334.     oRestriction.User = ""
  335. End Sub
  336.  
  337. ' ***
  338. ' *** ------------------------------------------------------------------------------
  339. ' *** Name:            LoadSection(sSection)
  340. ' *** ------------------------------------------------------------------------------
  341. ' *** Purpose:        Loads a users settings into a section
  342. ' *** ------------------------------------------------------------------------------
  343. ' ***
  344. Sub LoadSection(oXML, sSection)
  345.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  346.     
  347.     Dim oSection, oRestrict, oNode, oChild, iValue
  348.  
  349.     ' ~~~ Turn on error handling
  350.     On Error Resume Next
  351.  
  352.     ' ~~~ Cycle through sections
  353.     For Each oSection In oXML.selectNodes("/restrictions/allrestrictions/section[@type=""" & sSection & """]")
  354.         ' ~~~ Cycle through all the restrictions in the section node
  355.         For Each oRestrict In oSection.childNodes
  356.             ' ~~~ Process node depending on type
  357.             Select Case Left(oRestrict.Attributes.GetNamedItem("id").Text,3)
  358.                 Case "txt"
  359.                     ' ~~~ If text, set field to value of first child
  360.                     document.all(oRestrict.Attributes.GetNamedItem("id").Text).Value = oRestrict.firstChild.Text
  361.                 Case "chk"
  362.                     iValue = -1
  363.                 
  364.                     ' ~~~ Cycle through all the pokes to work out value
  365.                     For Each oNode In oRestrict.childNodes
  366.                         If TypeName(oNode.GetAttribute("ignore")) <> "String" Then
  367.                             If oNode.Attributes.GetNamedItem("on").Text = oNode.Text Then
  368.                                 iValue = GetChildValue(iValue, 1)
  369.                             Else
  370.                                 iValue = GetChildValue(iValue, 0)
  371.                             End If
  372.                         End If
  373.                     Next
  374.                     
  375.                     ' ~~~ Set the control
  376.                     document.all(oRestrict.Attributes.GetNamedItem("id").Text).value = iValue
  377.                     document.all(oRestrict.Attributes.GetNamedItem("id").Text).save
  378.             End Select
  379.         Next
  380.  
  381.         ' ~~~ If this isn't the general section we need to set the value of the section checkboxes
  382.         If sSection <> "general" and sSection = "allrestrictions" Then
  383.             For Each oChild in document.all("div" & oSection.Attributes.GetNamedItem("id").Text).getElementsByTagName("checkbox")
  384.                 iValue = GetChildValue(iValue, oChild.value)
  385.             Next
  386.  
  387.             ' ~~~ Set the control
  388.             document.all("chk" & oSection.Attributes.GetNamedItem("id").Text).value = iValue
  389.             document.all("chk" & oSection.Attributes.GetNamedItem("id").Text).save
  390.         End If
  391.     Next
  392.  
  393.     ' ~~~ Destroy xml objects
  394.     Set oSection = Nothing
  395.     Set oNode    = Nothing
  396.     
  397.     ' ~~~ For optional restrictions 
  398.     For Each oSection In oXML.selectNodes("/restrictions/optionalrestrictions/section[@type=""" & sSection & """]")
  399.         ' ~~~ Cycle through all the restrictions in the section node
  400.         For Each oRestrict In oSection.childNodes
  401.             ' ~~~ Process node depending on type
  402.             Select Case Left(oRestrict.Attributes.GetNamedItem("id").Text,3)
  403.                 Case "chk"
  404.                     ' ~~~ Cycle through all the pokes to work out value
  405.                     For Each oNode In oRestrict.childNodes
  406.                         If oNode.Attributes.GetNamedItem("on").Text = oNode.Text Then
  407.                             ' ~~~ Set the control
  408.                             document.all(oRestrict.Attributes.GetNamedItem("id").Text).checked = True
  409.                         Else
  410.                             document.all(oRestrict.Attributes.GetNamedItem("id").Text).checked = False
  411.                         End If
  412.                         
  413.                     Next
  414.             End Select
  415.         Next
  416.     Next
  417.     
  418.     ' ~~~ Destroy xml objects
  419.     Set oSection = Nothing
  420.     Set oNode    = Nothing
  421. End Sub
  422.  
  423. ' ***
  424. ' *** ------------------------------------------------------------------------------
  425. ' *** Name:            SaveSection(sSection)
  426. ' *** ------------------------------------------------------------------------------
  427. ' *** Purpose:        Saves a users settings from a section
  428. ' *** ------------------------------------------------------------------------------
  429. ' ***
  430. Sub SaveSection(oXML, sSection)
  431.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  432.     
  433.     Dim oSection, oNode, IdleLogoff
  434.     
  435.     ' ~~~ Turn on error handling
  436.     On Error Resume Next
  437.     
  438.     ' ~~~ Cycle through sections
  439.     For Each oSection In oXML.selectNodes("/restrictions/allrestrictions/section[@type=""" & sSection & """]")
  440.         ' ~~~ Cycle through pokes, setting values
  441.         For Each oNode In oSection.getElementsByTagName("poke")
  442.             ' ~~~ Process node depending on type
  443.             
  444.             Call oLog.Write("Restrict.hta : " & oNode.Attributes.GetNamedItem("resid").Text)
  445.  
  446.             Select Case Left(oNode.Attributes.GetNamedItem("resid").Text,3)
  447.                 Case "chk"
  448.                     Select Case document.all(oNode.Attributes.GetNamedItem("resid").Text).value
  449.                         Case 0
  450.                             oNode.Text = oNode.Attributes.GetNamedItem("off").Text
  451.                         Case 1
  452.                             oNode.Text = oNode.Attributes.GetNamedItem("on").Text
  453.                         Case 2
  454.                             ' do nothing
  455.                     End Select
  456.  
  457.                 Case "txt"
  458.                     If oNode.Attributes.GetNamedItem("resid").Text = "txtLogoffInactive" Then
  459.                         If oNode.Attributes.GetNamedItem("on").Text <> "" Then
  460.                             If document.all(oNode.Attributes.GetNamedItem("resid").Text).value <> "" Then
  461.                                 If Right(oNode.Attributes.GetNamedItem("regkey").Text,17) = "ScreenSaveTimeOut" Then
  462.                                     If IdleLogoff > 0 Then
  463.                                         oNode.Text = (IdleLogoff * 60) - 15    
  464.                                     End If
  465.                                 Else
  466.                                     oNode.Text = oShell.ExpandEnvironmentStrings(oNode.Attributes.GetNamedItem("on").Text)
  467.                                 End If
  468.                             Else
  469.                                 If UCase(sCurrentScrSvr) = "FORCELOGOFF.EXE" Then 
  470.                                     oNode.Text = oShell.ExpandEnvironmentStrings(oNode.Attributes.GetNamedItem("off").Text)
  471.                                 End If
  472.                             End If
  473.                         Else
  474.                             oNode.Text = document.all(oNode.Attributes.GetNamedItem("resid").Text).value
  475.                             IdleLogoff = document.all(oNode.Attributes.GetNamedItem("resid").Text).value
  476.                         End If
  477.                     Else
  478.                         If oNode.Attributes.GetNamedItem("on").Text <> "" Then
  479.                             If document.all(oNode.Attributes.GetNamedItem("resid").Text).value <> "" Then
  480.                                 oNode.Text = oNode.Attributes.GetNamedItem("on").Text
  481.                             Else
  482.                                 oNode.Text = oNode.Attributes.GetNamedItem("off").Text
  483.                             End If
  484.                         Else
  485.                             oNode.Text = document.all(oNode.Attributes.GetNamedItem("resid").Text).value
  486.                         End If
  487.                     End If
  488.             End Select
  489.         Next
  490.     Next
  491.     
  492.     ' ~~~ Destroy xml objects
  493.     Set oSection = Nothing
  494.     Set oNode    = Nothing
  495.     
  496.     ' ~~~ For Optional restrictions
  497.     ' ~~~ Cycle through sections
  498.         
  499.     For Each oSection In oXML.selectNodes("/restrictions/optionalrestrictions/section[@type=""" & sSection & """]")
  500.         ' ~~~ Cycle through pokes, setting values
  501.         For Each oNode In oSection.getElementsByTagName("poke")
  502.             ' ~~~ Process node depending on type
  503.             Call oLog.Write("Restrict.hta : " & oNode.Attributes.GetNamedItem("resid").Text)
  504.             Select Case Left(oNode.Attributes.GetNamedItem("resid").Text,3)
  505.                 Case "chk"
  506.                     If document.all(oNode.Attributes.GetNamedItem("resid").Text).Checked Then
  507.                         oNode.Text = oNode.Attributes.GetNamedItem("on").Text
  508.                     Else
  509.                         oNode.Text = oNode.Attributes.GetNamedItem("off").Text
  510.                     End If
  511.             End Select
  512.         Next
  513.     Next
  514.     
  515.     ' ~~~ Destroy xml objects
  516.     Set oSection = Nothing
  517.     Set oNode    = Nothing
  518. End Sub
  519.  
  520. ' ***
  521. ' *** ------------------------------------------------------------------------------
  522. ' *** Name:            ChangeDisableInternet()
  523. ' *** ------------------------------------------------------------------------------
  524. ' *** Purpose:        If use select disable internet, disable homepage and proxy fields
  525. ' *** ------------------------------------------------------------------------------
  526. ' ***
  527. Sub ChangeDisableInternet()
  528.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  529.     
  530.     ' ~~~ To Enable apply button 
  531.     If txtAccount.value <> "" Then
  532.         btnApply.disabled = False
  533.         If chkDisableInternet.Checked Then
  534.             txtProxy.Value         = "NoInternetAccess"
  535.             txtProxy.Disabled    = True
  536.         Else
  537.             If document.all("txtProxy").Value  = "NoInternetAccess" Then
  538.                 document.all("txtProxy").Value = ""
  539.             End If
  540.             txtProxy.Disabled    = False
  541.         End If
  542.     Else
  543.         chkDisableInternet.checked = False
  544.     End If
  545. End Sub
  546.  
  547. ' ***
  548. ' *** ------------------------------------------------------------------------------
  549. ' *** Name:            ChangeDisableInternetLoad()
  550. ' *** ------------------------------------------------------------------------------
  551. ' *** Purpose:        If use select disable internet, disable homepage and proxy fields
  552. ' ***            This function gets called while loading the profile settings
  553. ' *** ------------------------------------------------------------------------------
  554. ' ***
  555. Sub ChangeDisableInternetLoad()
  556.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  557.     
  558.     ' ~~~ To Enable apply button 
  559.     If txtAccount.value <> "" Then
  560.         If chkDisableInternet.Checked Then
  561.             txtProxy.Value       = "NoInternetAccess"
  562.             txtProxy.Disabled    = True
  563.         Else
  564.             If txtProxy.Value = "NoInternetAccess" Then
  565.                 txtProxy.Value = ""
  566.             End If
  567.             txtProxy.Disabled    = False
  568.         End If
  569.     End If
  570. End Sub
  571.  
  572. ' ***
  573. ' *** ------------------------------------------------------------------------------
  574. ' *** Name:            ShowHideSection(sSection)
  575. ' *** ------------------------------------------------------------------------------
  576. ' *** Purpose:        Shows or Hiides a resrictions section
  577. ' *** ------------------------------------------------------------------------------
  578. ' ***
  579. Sub ShowHideSection(sSection)
  580.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  581.     
  582.     If document.all("div" & sSection).style.display = "block" Then
  583.         document.all("div" & sSection).style.display = "none"
  584.         ' ~~~ Change the image of the treeview to expand
  585.         document.all("img" & sSection).src = "graphics/tickit.gif"
  586.         
  587.         Call window.scrollto(0,0)
  588.     Else
  589.         document.all("div" & sSection).style.display = "block"
  590.         ' ~~~ Change the image of the treeview to collapse  
  591.         document.all("img" & sSection).src = "graphics/crossit.gif"
  592.         ' ~~~ To scroll the selected restrictions to top
  593.         document.all("sp" & sSection).Scrollintoview(True)
  594.         Call window.scrollto(0,0)
  595.     End If
  596. End Sub
  597.  
  598. ' ***
  599. ' *** ------------------------------------------------------------------------------
  600. ' *** Name:            ClearFields()
  601. ' *** ------------------------------------------------------------------------------
  602. ' *** Purpose:        Saves a users settings
  603. ' *** ------------------------------------------------------------------------------
  604. ' ***
  605. Sub ClearFields()
  606.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  607.     
  608.     Dim oField
  609.  
  610.     ' ~~~ Clear all input elements
  611.     For Each oField in document.getElementsByTagName("input")
  612.         oField.Value = ""
  613.     Next
  614.     
  615.     ' ~~~ Clear all check boxes
  616.     For Each oField in document.getElementsByTagName("checkbox")
  617.         oField.Value = 0
  618.     Next
  619.     
  620.     ' ~~~ Clear the dd list
  621.     document.all("txtAccessDisks").value = ""
  622. End Sub
  623.  
  624. ' ***
  625. ' *** ------------------------------------------------------------------------------
  626. ' *** Name:            GetChildValue(iResult, iChild)
  627. ' *** ------------------------------------------------------------------------------
  628. ' *** Purpose:        Used to work out the overall value of multiple children
  629. ' ***                returns 0,1,2 : off, on, grey
  630. ' *** ------------------------------------------------------------------------------
  631. ' ***
  632. Function GetChildValue(iResult, iChild)
  633.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  634.     
  635.     Dim iNewResult
  636.     
  637.     If (iResult=-1) or (iResult=iChild) Then
  638.         iNewResult = iChild
  639.     Else
  640.         iNewResult = 2
  641.     End If
  642.     
  643.     GetChildValue = iNewResult
  644. End Function
  645.  
  646. ' ***
  647. ' *** ------------------------------------------------------------------------------
  648. ' *** Name:            Bubble(oItem)
  649. ' *** ------------------------------------------------------------------------------
  650. ' *** Purpose:        Bubble the state of a checkbox throughout the tree when clicked
  651. ' *** ------------------------------------------------------------------------------
  652. ' ***
  653. Sub Bubble(oItem)
  654.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  655.     
  656.     Dim sChkId, bTextClick, oChkItem 
  657.     
  658.     If document.all("txtAccount").value = "" Then
  659.         If oItem.tagname = "checkbox" Then
  660.             ' ~~~ If no account is selected make the check box zero
  661.             document.all(oItem.id).value = 0
  662.         End If
  663.     Else
  664.         ' ~~~ To Enable apply button 
  665.         Call Change_value()
  666.     
  667.         bTextClick = False
  668.         ' ~~~ Check if the text is clicked
  669.         If Left(oItem.id,2) = "sp" Then 
  670.             ' ~~~ Extract the checkbox id from the span id that is clicked
  671.             sChkId = Mid(oItem.Id,3)
  672.             ' ~~~ Get the object of the coressponding checkbox 
  673.             Set oChkItem = document.all(sChkId)
  674.             bTextClick = True
  675.         End If
  676.         If bTextClick = True Then
  677.             ' ~~~ Generate the onclick event of the checkbox
  678.             oChkItem.Click
  679.             Call BubbleDown(oChkItem)
  680.         Else
  681.             Call BubbleDown(oItem)
  682.         End If
  683.         Call BubbleUp()
  684.     End If    
  685. End Sub
  686.  
  687. ' ***
  688. ' *** ------------------------------------------------------------------------------
  689. ' *** Name:            BubbleDown(oItem)
  690. ' *** ------------------------------------------------------------------------------
  691. ' *** Purpose:        Bubble the state of a checkbox down
  692. ' *** ------------------------------------------------------------------------------
  693. ' ***
  694. Sub BubbleDown(oItem)
  695.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  696.     
  697.     Dim oDiv, oChk, oChild
  698.     Dim colTable, oTable
  699.  
  700.     ' ~~~ bubble down
  701.     Set oChk = document.all("chk" & Mid(oItem.id,4))
  702.     Set oDiv = document.all("div" & Mid(oItem.id,4))
  703.          
  704.     If Not(oDiv is nothing) and Not(oChk is nothing) Then
  705.         Set colTable = oDiv.getElementsByTagName("TABLE") 
  706.         For Each oTable in colTable
  707.             For Each oChild in oTable.all
  708.                 Select Case UCase(oChild.TagName)
  709.                     Case "CHECKBOX"
  710.                         If oChk.value = 2 Then
  711.                             oChild.load
  712.                             oChild.value = 0
  713.                         Else
  714.                             oChild.value = oChk.value
  715.                         End If
  716.  
  717.                     Case "DIV"
  718.                         Call BubbleDown(oChild)
  719.                 End Select
  720.             Next
  721.         Next
  722.     End If
  723. End Sub
  724.  
  725. ' ***
  726. ' *** ------------------------------------------------------------------------------
  727. ' *** Name:            BubbleUp(oItem)
  728. ' *** ------------------------------------------------------------------------------
  729. ' *** Purpose:        Bubble the state of a checkbox up
  730. ' *** ------------------------------------------------------------------------------
  731. ' ***
  732. Sub BubbleUp()
  733.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  734.  
  735.     Dim oSection, oChild, iValue, iValue2
  736.  
  737.     ' ~~~ Check if the messages need to be displayed for the user 
  738.     If iUserMessages and bUserMessages Then
  739.         If RestrictMessage(document.all("chkRestrictions").value) Then Exit Sub
  740.     Else
  741.         Call UserSessionReg(oNetwork.UserName)
  742.     End If
  743.         
  744.     iValue2 = -1
  745.     For Each oSection in document.all("divRestrictions").getElementsByTagName("div")
  746.         iValue = -1
  747.         For Each oChild in oSection.getElementsByTagName("checkbox")
  748.             iValue = GetChildValue(iValue, oChild.value)
  749.         Next
  750.         document.all("chk" & Mid(oSection.id,4)).value = iValue        
  751.         iValue2 = GetChildValue(iValue2, iValue)
  752.     Next
  753.  
  754.     document.all("chkRestrictions").value = iValue2
  755.     
  756. End Sub
  757.  
  758.  
  759. ' ***
  760. ' *** ------------------------------------------------------------------------------
  761. ' *** Name:            SelectProfile()
  762. ' *** ------------------------------------------------------------------------------
  763. ' *** Purpose:        Called when the Select a Profile is clicked
  764. ' *** ------------------------------------------------------------------------------
  765. ' ***
  766. Sub SelectProfile()
  767.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  768.  
  769.     Dim strUser
  770.  
  771.     bProcessing = True
  772.  
  773.     ' ~~~ Before selecting a new profile check whether the currently selected profile has change or not
  774.     If (btnApply.disabled = False) and (txtAccount.value <> "") Then
  775.         If MsgBox (resChangeProfile.innerHTML,vbYesNo+vbInformation,sTitle) = vbYes Then
  776.             Call Apply()
  777.         Else
  778.             btnApply.disabled = true
  779.         End If    
  780.     End If
  781.  
  782.     ' ~~~ Get the return value from the modal dialog
  783.     strUser = Window.ShowModalDialog("UserAccounts.hta", "Restrictions", "dialogWidth:15;dialogHeight:10;Center:Yes;help:No;Resizable:No;")
  784.  
  785.     If NOT IsEmpty(strUser) Then
  786.         txtAccount.value = strUser(1)
  787.         ' ~~~ Store the user account name
  788.         sAccountName = strUser(0)
  789.     End If
  790.  
  791.     If txtAccount.value = "" Then
  792.         DisableAllControls(True)
  793.         btnApply.disabled = true
  794.     Else
  795.         ' ~~~ Check if the user logged on through fast user switching when administrator is applying restrictions.
  796.         ' ~~~ The HTA is kept open and the user account displayed is logged on through fast user switching.
  797.         If Not oRestriction.IsUserLoggedOn(sAccountName) Then
  798.             DisableAllControls(False)
  799.             ' ~~~ Call the change user function
  800.             ChangeUser
  801.         End If
  802.     End If
  803.  
  804.     bProcessing = False
  805. End Sub
  806.  
  807. ' ***
  808. ' *** ------------------------------------------------------------------------------
  809. ' *** Name:        Apply()
  810. ' *** ------------------------------------------------------------------------------
  811. ' *** Purpose:    Applies the restrictions for the profile selected
  812. ' *** ------------------------------------------------------------------------------
  813. ' ***
  814. Sub Apply()
  815.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  816.     
  817.     ' ~~~ To change the cursor to wait icon
  818.     bProcessing = True
  819.     Call BodyDisable(True)
  820.     
  821.     ' ~~~ To check if the Apply() is called from Apply or OK button
  822.     If (window.event.srcelement.id) = "btnApply" Then
  823.         ' ~~~ Disable the OK button and text
  824.         DisableFinish(True)
  825.     End If
  826.     
  827.     ' ~~~ Save the restrictions if the profile is changed
  828.     If document.all("txtAccount").value <> "" Then
  829.         If oRestriction.GetProfilePath(sAccountName) <> "" Then
  830.             If Not oRestriction.IsUserLoggedOn(sAccountName) Then
  831.                 Call SaveUser()
  832.                 RestrictSelectedProfile()
  833.                 If Not(bLockError) Then Msgbox document.all("txtAccount").value & " " & document.all("resAppliedChanges").innerHTML , vbInformation , sTitle
  834.             Else
  835.                 Msgbox resUserLogonError.innerHTML, vbOKOnly+vbCritical, sTitle    
  836.             End If
  837.         Else
  838.             Msgbox resUserNoProfileError.innerHTML, vbOKOnly+vbCritical, sTitle
  839.         End If
  840.     End If
  841.     ' ~~~ To change the cursor to default icon
  842.     Call BodyDisable(False)
  843.     btnApply.OnMouseout()
  844.     btnApply.disabled = true
  845.  
  846.     ' ~~~ Enable the OK button and text
  847.     DisableFinish(False)
  848.     Call CheckFilesystem()
  849.     bProcessing = False
  850. End Sub
  851.  
  852. ' ***
  853. ' *** ------------------------------------------------------------------------------
  854. ' *** Name:            RestrictSelectedProfile()
  855. ' *** ------------------------------------------------------------------------------
  856. ' *** Purpose:        This subroutine performs the actual functionality of the tool
  857. ' ***            Selected profile is restricted
  858. ' *** ------------------------------------------------------------------------------
  859. ' ***
  860. Sub RestrictSelectedProfile()
  861.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  862.     
  863.     Dim oFile, sProfile
  864.     
  865.     sProfile = sAccountName
  866.     If sProfile <> "" Then
  867.         ' ~~~ Process all of the xml files
  868.         If  oFso.FileExists(GetRootFolder & "\xml\" & "User." & sProfile & ".xml") Then
  869.             oRestriction.User = sProfile
  870.             If oRestriction.AccountLocked(sProfile) = False AND oFso.FolderExists(oRestriction.GetProfilePath(sProfile) & ".orig") Then
  871.                 If Msgbox(resLockOrigDelete.innerHTML,VBYesNo + VBQuestion,sTitle) = VBYes Then
  872.                     oRestriction.ChangeLockFolder = False
  873.                 Else
  874.                     oRestriction.ChangeLockFolder = True
  875.                 End If
  876.             End If
  877.             oRestriction.ApplyXML
  878.             bLockError = False    
  879.             If oRestriction.AccountLocked(sProfile) = False and chkSharedAccount.value = 1 Then 
  880.                 MsgBox document.all("resLockError").innerHTML, vbOKOnly+vbCritical, sTitle
  881.                 chkSharedAccount.value = 0
  882.                 bLockError = True
  883.             End If
  884.         End If
  885.     End If
  886. End Sub
  887.  
  888. ' ***
  889. ' *** ------------------------------------------------------------------------------
  890. ' *** Name:            Change_value()
  891. ' *** ------------------------------------------------------------------------------
  892. ' *** Purpose:        This subroutine is called when the value in the edit boxes 
  893. ' ***            are changing.It enables the Apply button
  894. ' *** ------------------------------------------------------------------------------
  895. ' ***
  896. Sub Change_value()
  897.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  898.  
  899.     If txtAccount.value = "" Then
  900.         chkSharedAccount.value = 0
  901.         chkForceRestart.value = 0
  902.         chkDisableInternet.checked = False
  903.         chkDisableMessenger.checked = False
  904.     Else
  905.         If window.event.srcelement.id = "chkSharedAccount" AND bFAT32Drive Then
  906.             chkSharedAccount.value = 0
  907.             Exit Sub
  908.         End If
  909.         
  910.         btnApply.disabled = False
  911.         
  912.         ' ~~~ To hide the popup's
  913.         If window.event.srcelement.id = "chkSharedAccount" Then
  914.             poponclick("Lock")
  915.         ElseIf window.event.srcelement.id = "chkRestrictions" Then 
  916.             poponclick("Restrict")
  917.         End If
  918.     End If
  919. End Sub
  920.  
  921. ' ***
  922. ' *** ------------------------------------------------------------------------------
  923. ' *** Name:            Validate_idle()
  924. ' *** ------------------------------------------------------------------------------
  925. ' *** Purpose:        This subroutine is called when the value in the edit boxes 
  926. ' ***            are changing.It enables the Apply button
  927. ' *** ------------------------------------------------------------------------------
  928. ' ***
  929. Sub Validate_idle()
  930.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  931.     
  932.     ' ~~~ Handle error in Log off Idle field
  933.     On Error Resume next
  934.  
  935.     btnApply.disabled = False
  936.     If txtLogoffInactive.value <> "" Then
  937.         Int(txtLogoffInactive.value)
  938.         If err.number <> 0 Then
  939.             ' ~~~ If idle value is not a numeric value
  940.             MsgBox resLogoffError.innerHTML, vbOKOnly+vbCritical, sTitle
  941.             Window.Event.ReturnValue = False
  942.             txtLogoffInactive.value = ""
  943.             txtLogoffInactive.SetActive()
  944.         Else
  945.             If txtLogoffInactive.value >= 0 AND txtLogoffInactive.value < 1 Then
  946.                 ' ~~~ If idle value is between 0 and 1 then, set it to 1
  947.                 txtLogoffInactive.value = 1
  948.             ElseIf txtLogoffInactive.value < 0 Then
  949.                 ' ~~~ If idle is negative, give the error message
  950.                 MsgBox resNegativeLogoffValue.innerHTML, vbOKOnly+vbCritical, sTitle
  951.                 Window.Event.ReturnValue = False
  952.                 txtLogoffInactive.value = ""
  953.                 txtLogoffInactive.SetActive()                
  954.                 Exit Sub
  955.             End If 
  956.             If txtLogoffMinsUse.value <> "" Then
  957.                 ' ~~~ If idle value is greater than logoff after use value
  958.                 If Int(txtLogoffMinsUse.value) < Int(txtLogoffInactive.value) Then
  959.                     MsgBox  resMoreLogoffIdleValue.innerHTML, vbOKOnly+vbCritical, sTitle
  960.                     Window.Event.ReturnValue = False
  961.                     txtLogoffInactive.SetActive()
  962.                 Else
  963.                     ' ~~~ Truncate the decimal part and display the value
  964.                     txtLogoffInactive.value = Int( txtLogoffInactive.value )
  965.                 End If
  966.             Else
  967.                 ' ~~~ Truncate the decimal part and display the value            
  968.                 txtLogoffInactive.value = Int( txtLogoffInactive.value )
  969.             End If
  970.         End If
  971.     End If
  972. End Sub
  973.  
  974. ' ***
  975. ' *** ------------------------------------------------------------------------------
  976. ' *** Name:            Validate_Use()
  977. ' *** ------------------------------------------------------------------------------
  978. ' *** Purpose:        This subroutine is called when the value in the edit boxes 
  979. ' ***            are changing.It enables the Apply button
  980. ' *** ------------------------------------------------------------------------------
  981. ' ***
  982. Sub Validate_Use()    
  983.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  984.     
  985.     ' ~~~ Handle error in two Log off minutes checkboxes
  986.     On Error Resume next
  987.  
  988.     btnApply.disabled = False
  989.     If txtLogoffMinsUse.value <> "" Then
  990.         Int(txtLogoffMinsUse.value)
  991.         If err.number <> 0 Then
  992.             ' ~~~ If the value is not numeric
  993.             MsgBox resLogoffError.innerHTML, vbOKOnly+vbCritical,sTitle
  994.             Window.Event.ReturnValue = False
  995.             txtLogoffMinsUse.value = ""
  996.             txtLogoffMinsUse.SetActive()
  997.         Else
  998.             If txtLogoffMinsUse.value >= 0 AND txtLogoffMinsUse.value < 5 Then
  999.                 ' ~~~ If the value is between 0 and 5, set it to 5
  1000.                 txtLogoffMinsUse.value = 5
  1001.             ElseIf txtLogoffMinsUse.value < 0 Then
  1002.                 ' ~~~ If the value is negative, give the error message 
  1003.                 MsgBox resNegativeLogoffValue.innerHTML, vbOKOnly+vbCritical, sTitle
  1004.                 Window.Event.ReturnValue = False
  1005.                 txtLogoffMinsUse.value = ""
  1006.                 txtLogoffMinsUse.SetActive()
  1007.                 Exit Sub
  1008.             End If
  1009.             
  1010.             If txtLogoffInactive.value <> "" Then
  1011.                 ' ~~~ If the Logoff after use value is less than idle logoff value
  1012.                 If Int(txtLogoffMinsUse.value) < Int(txtLogoffInactive.value) Then
  1013.                     MsgBox resLessLogoffUseValue.innerHTML, vbOKOnly+vbCritical, sTitle
  1014.                     Window.Event.ReturnValue = False
  1015.                     txtLogoffMinsUse.SetActive()
  1016.                 Else
  1017.                     ' ~~~ Truncate the decimal part and display the value
  1018.                     txtLogoffMinsUse.value = Int( txtLogoffMinsUse.value )                 
  1019.                 End If
  1020.             Else
  1021.                 ' ~~~ Truncate the decimal part and display the value
  1022.                 txtLogoffMinsUse.value = Int( txtLogoffMinsUse.value )                 
  1023.             End If
  1024.         End If
  1025.     End If
  1026. End Sub
  1027.  
  1028. ' ***
  1029. ' *** ------------------------------------------------------------------------------
  1030. ' *** Name:            DisableAllControls()
  1031. ' *** ------------------------------------------------------------------------------
  1032. ' *** Purpose:        Enables/Disables all the controls If a User account is selected 
  1033. ' *** ------------------------------------------------------------------------------
  1034. ' ***
  1035. Sub DisableAllControls(bEnable)
  1036.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1037.     
  1038.     txtHomePage.disabled = bEnable
  1039.     txtProxy.disabled = bEnable
  1040.     txtProxyOverride.Disabled    = bEnable
  1041.     txtLogoffMinsUse.disabled = bEnable
  1042.     txtLogoffInactive.disabled = bEnable
  1043.     txtAccessDisks.disabled = bEnable
  1044.     btnAccessDisks.disabled = bEnable    
  1045. End sub
  1046.  
  1047. ' ***
  1048. ' *** ------------------------------------------------------------------------------
  1049. ' *** Name:            ClickText(chkId)
  1050. ' *** ------------------------------------------------------------------------------
  1051. ' *** Purpose:        This method is called when the user clicks on the text of the checkbox
  1052. ' *** ------------------------------------------------------------------------------
  1053. ' ***
  1054. Function ClickText(checkId)
  1055.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1056.  
  1057.     ' ~~~ Enable only if user account is selected.
  1058.     If txtAccount.value <> "" Then
  1059.         checkId.Click
  1060.     End If
  1061. End Function
  1062.  
  1063. ' ***
  1064. ' *** ------------------------------------------------------------------------------
  1065. ' *** Name:            DisableFinish(bToggle)
  1066. ' *** ------------------------------------------------------------------------------
  1067. ' *** Purpose:        Enables/Disables all the Finish text and button on Apply
  1068. ' *** ------------------------------------------------------------------------------
  1069. ' ***
  1070. Sub DisableFinish(bToggle)
  1071.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1072.     
  1073.     If bToggle = True Then
  1074.         btnFinish.disabled = True
  1075.         btnFinish.style.cursor = "auto"
  1076.     Else
  1077.         btnFinish.disabled = False
  1078.         btnFinish.style.cursor = "hand"
  1079.     End If
  1080.     
  1081. End Sub
  1082.  
  1083. ' ***
  1084. ' *** ------------------------------------------------------------------------------
  1085. ' *** Name:            DrivesPopup()
  1086. ' *** ------------------------------------------------------------------------------
  1087. ' *** Purpose:        This method is called to popup the selectdrives.hta
  1088. ' *** ------------------------------------------------------------------------------
  1089. ' ***
  1090. Sub DrivesPopup
  1091.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1092.  
  1093.     bProcessing = True
  1094.     
  1095.     If txtAccount.value <> "" Then
  1096.         Dim intDrives
  1097.         
  1098.         intDrives = Window.ShowModalDialog("SelectDrives.hta", txtAccessDisks.value,"dialogWidth:20;dialogHeight:18;Center:Yes;help:No;Resizable:No;")
  1099.         ' ~~~ Assign the returned decimal value to the txtAccessDisks
  1100.         
  1101.         If intDrives <> "" Then
  1102.             ' ~~~ Enable apply only if the drive value changes 
  1103.             If txtAccessDisks.value = "" Then txtAccessDisks.value = 0 
  1104.             If Int(txtAccessDisks.value) <> Int(intDrives) Then
  1105.                 ' ~~~ Call the change value sub
  1106.                 Change_value()
  1107.             End If
  1108.             txtAccessDisks.value = intDrives
  1109.         End If
  1110.     End If
  1111.  
  1112.     bProcessing = False
  1113. End Sub
  1114.  
  1115. ' ***
  1116. ' *** ------------------------------------------------------------------------------
  1117. ' *** Name:            HTAKeyDown()
  1118. ' *** ------------------------------------------------------------------------------
  1119. ' *** Purpose:        This is the handler function for tool specific key controls
  1120. ' *** ------------------------------------------------------------------------------
  1121. ' ***
  1122. Sub HTAKeyDown()
  1123.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0    
  1124.     Dim sElement, sParent
  1125.     
  1126.     sElement = window.event.srcelement.id
  1127.     sParent = window.event.srcelement.parentnode.id
  1128.     
  1129.     Select Case(window.event.keycode)
  1130.         Case 32 
  1131.             If mid(sElement,1,3) = "chk" Then
  1132.                 If sParent <> "divAdditional" and sParent <> "divProgramIcons" Then 
  1133.                     ' ~~~ Generate the click event only for the 3-state checkboxes.
  1134.                     document.all(sElement).Click
  1135.                 End If
  1136.             End If
  1137.         Case 37 ' ~~~ Collapse
  1138.             If sElement = "chkStartMenu" or sElement = "chkWindows" or sElement = "chkIExplorer" or sElement = "chkOffice" or sElement = "chkSRPSection" or sElement = "imgAdditionalStartMenu" or sElement = "imgAdditionalWinXP" or sElement = "imgAdditionalIE" or sElement =  "imgAdditional" Then
  1139.                 If document.all("div" & mid(sElement,4)).style.display <> "none" Then
  1140.                     ShowHideSection(mid(sElement,4))
  1141.                 End If
  1142.             ElseIf sParent = "divStartMenu" or sParent = "divWindows" or sParent = "divIExplorer" or sParent = "divOffice" or sParent = "divSRPSection" Then
  1143.                 ShowHideSection(mid(sParent,4))
  1144.                 document.all("chk" & mid(sParent,4)).focus
  1145.             End If
  1146.         Case 39 ' ~~~ Expand
  1147.             If sElement = "chkStartMenu" or sElement = "chkWindows" or sElement = "chkIExplorer" or sElement = "chkOffice" or sElement = "chkSRPSection" or sElement = "imgAdditionalStartMenu" or sElement = "imgAdditionalWinXP" or sElement = "imgAdditionalIE" or sElement =  "imgAdditional"  Then
  1148.                 If document.all("div" & mid(sElement,4)).style.display = "none" Then
  1149.                     ShowHideSection(mid(sElement,4))
  1150.                 End If
  1151.             End If
  1152.         Case 40
  1153.             If mid(sElement,1,3) = "chk" or mid(sElement,1,3) = "img" Then
  1154.                 window.event.keycode = 9
  1155.             End If
  1156.         Case 38
  1157.         Case 9
  1158.         Case 27
  1159.         
  1160.     End Select
  1161.  
  1162.     If bShowPopup Then ShowHidePopup()
  1163.     
  1164. End Sub
  1165.  
  1166. ' ***
  1167. ' *** ------------------------------------------------------------------------------
  1168. ' *** Name:            ShowHidePopup()
  1169. ' *** ------------------------------------------------------------------------------
  1170. ' *** Purpose:        This is the method to show the popup's 
  1171. ' *** ------------------------------------------------------------------------------
  1172. ' ***
  1173. Sub ShowHidePopup()
  1174.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0    
  1175.     Dim oLockPopBody, oResPopBody, ipopHeight, oLockAgainPopBody
  1176.     Dim oAccount, strProfilePath, iDivScrollTop , iChkOffsetValue  
  1177.     
  1178.     ipopHeight = 0
  1179.     strProfilePath = ""
  1180.     
  1181.     Set oAccount = GetObject("WinNT://" & sComputer & "/" & sAccountName)
  1182.     strProfilePath = oAccount.Profile
  1183.     
  1184.     iDivScrollTop = divGeneralSettings.ScrollTop
  1185.     
  1186.     If document.all("chkSharedAccount").Value = 0 and bShowLockPopup = True and strProfilePath = "" Then
  1187.         Set oLockPopBody = oLockPopup.document.body
  1188.         oLockPopBody.style.backgroundColor = popupBackgroundColor.innerText
  1189.         oLockPopBody.style.border          = popupBorder.innerText
  1190.         oLockPopBody.style.padding         = popupPadding.innerText
  1191.         oLockPopBody.style.Color           = popupColor.innerText
  1192.         oLockPopBody.style.Font            = popBodyFont.innerText
  1193.         oLockPopBody.innerHTML = "<div onclick=""parent.poponclick('Lock')"">" +  document.all("popLockMessage").innerHTML + "</div>" 
  1194.                 
  1195.         oLockPopup.Hide()
  1196.         iChkOffsetValue = chkSharedAccount.offsetparent.offsetTop + chkSharedAccount.offsetHeight
  1197.         
  1198.         If iDivScrollTop <= iChkOffsetValue Then        
  1199.             oLockPopup.show 10, 10, 250, 100, chkSharedAccount
  1200.             ipopHeight = oLockPopBody.scrollHeight 
  1201.             oLockPopup.show 10, 10, 250, ipopHeight, chkSharedAccount
  1202.         End If
  1203.         
  1204.         bShowLockPopup = True
  1205.         bShowPopup = True
  1206.         Exit Sub
  1207.     End If
  1208.     
  1209.     If document.all("chkSharedAccount").Value = 0 and bLockAgainPopup = True and strProfilePath <> "" Then
  1210.         Set oLockAgainPopBody = oLockAgainPopup.document.body
  1211.         oLockAgainPopBody.innerHTML = "<div onclick=""parent.poponclick('LockAgain')"">" +  document.all("resLockAgainMessage").innerHTML + "</div>" 
  1212.         oLockAgainPopBody.style.backgroundColor = LockAgainpopupBackground.innerText
  1213.         oLockAgainPopBody.style.border          = popupBorder.innerText
  1214.         oLockAgainPopBody.style.padding         = popupPadding.innerText
  1215.         oLockAgainPopBody.style.Color           = popupColor.innerText
  1216.         oLockAgainPopBody.style.Font            = popBodyFont.innerText
  1217.         
  1218.         oLockAgainPopup.Hide()
  1219.         iChkOffsetValue = chkSharedAccount.offsetparent.offsetTop + chkSharedAccount.offsetHeight
  1220.                     
  1221.         If iDivScrollTop <= iChkOffsetValue Then
  1222.             oLockAgainPopup.show 10, 10, 250, 100, chkSharedAccount
  1223.             ipopHeight = oLockAgainPopBody.scrollHeight 
  1224.             oLockAgainPopup.show 10, 10, 250, ipopHeight, chkSharedAccount
  1225.         End If
  1226.         
  1227.         bLockAgainPopup = True
  1228.         bShowPopup = True
  1229.         Exit Sub
  1230.     End If
  1231.     
  1232.     If document.all("chkRestrictions").Value = 0 and bShowResPopup = True and strProfilePath = "" Then
  1233.         Set oResPopBody = oRestrictPopup.document.body
  1234.         oResPopBody.style.backgroundColor = popupBackgroundColor.innerText
  1235.         oResPopBody.style.border          = popupBorder.innerText
  1236.         oResPopBody.style.padding         = popupPadding.innerText
  1237.         oResPopBody.style.Color           = popupColor.innerText
  1238.         oResPopBody.style.Font            = popBodyFont.innerText
  1239.         oResPopBody.innerHTML = "<div onclick=""parent.poponclick('Restrict')"" >" +  document.all("popRestrictMessage").innerHTML + "</div>" 
  1240.         
  1241.         oRestrictPopup.Hide()
  1242.         iChkOffsetValue = chkRestrictions.offsetTop + chkRestrictions.offsetHeight
  1243.             
  1244.         If iDivScrollTop <= iChkOffsetValue Then
  1245.             oRestrictPopup.show 10, 16, 300, 100, chkRestrictions
  1246.             ipopHeight = oResPopBody.scrollHeight 
  1247.             oRestrictPopup.show 10, 16, 300, ipopHeight, chkRestrictions
  1248.         End If
  1249.         
  1250.         bShowResPopup = True
  1251.         bLockAgainPopup = False
  1252.         bShowPopup = True
  1253.     End If
  1254.     
  1255. End Sub
  1256.  
  1257. ' ***
  1258. ' *** ------------------------------------------------------------------------------
  1259. ' *** Name:            UserSessionReg(sUserName)
  1260. ' *** ------------------------------------------------------------------------------
  1261. ' *** Purpose:        This is the method to store user's session in HKLM for
  1262. ' ***            displaying the messages first time.
  1263. ' *** ------------------------------------------------------------------------------
  1264. ' ***
  1265. Sub UserSessionReg(sUserName)
  1266.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1267.     
  1268.     iUserMessages = RegRead(TOOLKITKEY & sUserName & "_RestrictMessages")
  1269.     
  1270.     If IsNull(iUserMessages) Then 
  1271.         Call RegWrite(TOOLKITKEY & sUserName & "_RestrictMessages" , "1","REG_SZ")
  1272.     End If
  1273.     
  1274.     iUserMessages = RegRead(TOOLKITKEY & sUserName & "_RestrictMessages")
  1275.     bUserMessages = True
  1276. End Sub
  1277.  
  1278. ' ***
  1279. ' *** ------------------------------------------------------------------------------
  1280. ' *** Name:            RestrictMessage(iChkboxValue)
  1281. ' *** ------------------------------------------------------------------------------
  1282. ' *** Purpose:        This is the method display messageboxes.
  1283. ' *** ------------------------------------------------------------------------------
  1284. ' ***
  1285. Function RestrictMessage(iChkboxValue)
  1286.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1287.     
  1288.     RestrictMessage = False
  1289.         
  1290.     ' ~~~ If All Restrictions Chk box is off
  1291.     If iChkboxValue = 0 and window.event.srcelement.id <> "chkRestrictions" and bUserMessages Then
  1292.         If Msgbox (document.all("resLowLevelRestrict").innerHTML & vbCrlf & vbCrlf & document.all("resLowLevelRestrict2").innerHTML, VBQuestion + VBYesNo, document.all("resAdvOperator").innerHTML) = VBNo Then
  1293.             ' ~~~ Reset the registry value for the user 
  1294.             Call RegWrite (TOOLKITKEY & oNetwork.UserName & "_RestrictMessages" , "1", "REG_SZ")
  1295.             iUserMessages = RegRead(TOOLKITKEY &  oNetwork.UserName & "_RestrictMessages")
  1296.             bUserMessages = False
  1297.             ' ~~~ Reset the checkbox clicked to original state
  1298.             document.all(window.event.srcelement.id).click
  1299.             ' ~~~ Return true to exit from the sub
  1300.             RestrictMessage = True
  1301.         Else
  1302.             Call RegWrite (TOOLKITKEY & oNetwork.UserName & "_RestrictMessages" , "0", "REG_SZ")
  1303.             iUserMessages = RegRead(TOOLKITKEY &  oNetwork.UserName & "_RestrictMessages")
  1304.         End If
  1305.         
  1306.     End If
  1307.     
  1308.     ' ~~~ If All Restrictions Chk box is on
  1309.     If iChkboxValue = 1 and window.event.srcelement.id <> "chkRestrictions" and bUserMessages Then
  1310.         If Msgbox (document.all("resAllRestrict").innerHTML & vbCrlf & vbCrlf & document.all("resAllRestrict2").innerHTML, VBQuestion + VBYesNo, document.all("resAdvOperator").innerHTML) = VBNo Then
  1311.             ' ~~~ Reset the registry value for the user 
  1312.             Call RegWrite (TOOLKITKEY & oNetwork.UserName & "_RestrictMessages" , "1", "REG_SZ")
  1313.             iUserMessages = RegRead(TOOLKITKEY &  oNetwork.UserName & "_RestrictMessages")
  1314.             bUserMessages = False    
  1315.             ' ~~~ Reset the checkbox clicked to original state
  1316.             document.all(window.event.srcelement.id).click
  1317.             ' ~~~ Return true to exit from the sub
  1318.             RestrictMessage = True
  1319.         Else
  1320.             ' ~~~ Reset the registry value for the user(not to display the message boxes again)
  1321.             Call RegWrite (TOOLKITKEY & oNetwork.UserName & "_RestrictMessages" , "0", "REG_SZ")    
  1322.             iUserMessages = RegRead(TOOLKITKEY &  oNetwork.UserName & "_RestrictMessages")
  1323.         End If
  1324.         
  1325.     End If
  1326. End Function
  1327.  
  1328. ' ***
  1329. ' *** ------------------------------------------------------------------------------
  1330. ' *** Name:            OptRestrictionsClick(strElement)
  1331. ' *** ------------------------------------------------------------------------------
  1332. ' *** Purpose:        This is the method to check/uncheck optional restrictions
  1333. ' ***            check boxes.
  1334. ' *** ------------------------------------------------------------------------------
  1335. ' ***
  1336. Sub OptRestrictionsClick(strElement)
  1337.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1338.      
  1339.     If document.all("txtAccount").value = "" Then
  1340.         If Left(strElement,2) = "sp" Then 
  1341.             document.all(Mid(strElement,3)).checked = False
  1342.         Else
  1343.             document.all(strElement).checked = False
  1344.         End If
  1345.     Else
  1346.         If Left(strElement,2) = "sp" Then document.all(Mid(strElement,3)).click 
  1347.         ' ~~~ To Enable apply button 
  1348.         Call Change_value()
  1349.     End If
  1350. End Sub
  1351.  
  1352. ' ***
  1353. ' *** ------------------------------------------------------------------------------
  1354. ' *** Name:            poponclick(sPopup)
  1355. ' *** ------------------------------------------------------------------------------
  1356. ' *** Purpose:        This is the method display toggle the two popup's.
  1357. ' *** ------------------------------------------------------------------------------
  1358. ' ***
  1359. Sub poponclick(sPopup)
  1360.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1361.     
  1362.     Dim oResPopBody,ipopHeight,iDivScrollTop , iChkOffsetValue
  1363.     
  1364.     iDivScrollTop = divGeneralSettings.ScrollTop
  1365.     iChkOffsetValue = chkRestrictions.offsetTop + chkRestrictions.offsetHeight
  1366.     
  1367.     Select Case sPopup
  1368.         Case "Lock"
  1369.         ' ~~~ Hide the popup of Lock Profile
  1370.         oLockPopup.Hide()
  1371.             bShowLockPopup = False
  1372.             
  1373.             ' ~~~ To show the popup for the restrictions if it is off
  1374.             If document.all("chkRestrictions").Value = 0 and bShowResPopup = True Then
  1375.                 set oResPopBody = oRestrictPopup.document.body
  1376.                 oResPopBody.style.backgroundColor = popupBackgroundColor.innerText
  1377.                 oResPopBody.style.border          = popupBorder.innerText
  1378.                 oResPopBody.style.padding         = popupPadding.innerText
  1379.                 oResPopBody.style.Color           = popupColor.innerText
  1380.                 oResPopBody.style.Font            = popBodyFont.innerText
  1381.                 oResPopBody.innerHTML = "<div  onclick=""parent.poponclick('Restrict')"" >" +  popRestrictMessage.innerHTML + "</div>" 
  1382.                 
  1383.                 oRestrictPopup.Hide()
  1384.                                 
  1385.                 If iDivScrollTop <= iChkOffsetValue Then
  1386.                     oRestrictPopup.show 10, 16, 300, 100, chkRestrictions
  1387.                     ipopHeight = oResPopBody.scrollHeight 
  1388.                     oRestrictPopup.show 10, 16, 300, ipopHeight, chkRestrictions
  1389.                 End If
  1390.             End If  
  1391.             
  1392.         Case "Restrict"
  1393.             ' ~~~ Hide the popup of Restrictions
  1394.             oRestrictPopup.Hide()
  1395.             bShowResPopup = False
  1396.         Case "LockAgain"
  1397.             ' ~~~ Hide the popup used to remind the user to lock the profile again
  1398.             oLockAgainPopup.Hide()
  1399.             bLockAgainPopup = False
  1400.             
  1401.             ' ~~~ To show the popup for the restrictions if it is off
  1402.             If document.all("chkRestrictions").Value = 0 and bShowResPopup = True Then
  1403.                 set oResPopBody = oRestrictPopup.document.body
  1404.                 oResPopBody.style.backgroundColor = popupBackgroundColor.innerText
  1405.                 oResPopBody.style.border          = popupBorder.innerText
  1406.                 oResPopBody.style.padding         = popupPadding.innerText
  1407.                 oResPopBody.style.Color           = popupColor.innerText
  1408.                 oResPopBody.style.Font            = popBodyFont.innerText
  1409.                 oResPopBody.innerHTML = "<div  onclick=""parent.poponclick('Restrict')"" >" +  popRestrictMessage.innerHTML + "</div>" 
  1410.  
  1411.                 oRestrictPopup.Hide()
  1412.  
  1413.                 If iDivScrollTop <= iChkOffsetValue Then
  1414.                     oRestrictPopup.show 10, 16, 300, 100, chkRestrictions
  1415.                     ipopHeight = oResPopBody.scrollHeight 
  1416.                     oRestrictPopup.show 10, 16, 300, ipopHeight, chkRestrictions
  1417.                 End If
  1418.             End If  
  1419.     End Select
  1420.     
  1421.     If bShowLockPopup = False and bShowResPopup = False Then bShowPopup = False
  1422.  
  1423. End Sub
  1424.  
  1425. ' ***
  1426. ' *** ------------------------------------------------------------------------------
  1427. ' *** Name:            BodyOnclick()
  1428. ' *** ------------------------------------------------------------------------------
  1429. ' *** Purpose:        This is the method is executed onclick of the body.
  1430. ' *** ------------------------------------------------------------------------------
  1431. ' ***
  1432. Sub BodyOnclick()
  1433.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1434.     Dim sElementId
  1435.     sElementId = window.event.srcelement.id 
  1436.     
  1437.     ' ~~~ To hide the lock again popup remainder when clicked on Lock This Profile text
  1438.     If sElementId  = "chkSharedAccount" and oLockAgainPopup.IsOpen Then 
  1439.         bLockAgainPopup = False
  1440.         oLockAgainPopup.Hide()
  1441.     End If
  1442.     
  1443.     ' ~~~ Call the ShowHidePopup sub to retain the popup messages
  1444.     ' ~~~ generally the popup messages vanish when clicked outside the popup 
  1445.     If sElementId  <> "btnSelectProfile" and sElementId  <> "chkSharedAccount" Then
  1446.         If bShowPopup Then ShowHidePopup()
  1447.     End If
  1448. End Sub
  1449.  
  1450. ' ***
  1451. ' *** ------------------------------------------------------------------------------
  1452. ' *** Name:            CheckFilesystem()
  1453. ' *** ------------------------------------------------------------------------------
  1454. ' *** Purpose:        Checks the file system of the drive in which the profile
  1455. ' ***            exists. If it is not NTFS, then disable the "Lock Profile"
  1456. ' ***            checkbox
  1457. ' *** ------------------------------------------------------------------------------
  1458. ' ***
  1459. Sub CheckFilesystem()
  1460.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1461.     
  1462.     bFAT32Drive = False
  1463.     
  1464.     If NOT oRestriction.IsFileSystemNTFS Then
  1465.         chkSharedAccount.Value = 0
  1466.         bShowLockPopup = False
  1467.         bLockAgainPopup = False
  1468.         bFAT32Drive = True
  1469.         
  1470.         spchkSharedAccount.Title = resLockProfileTooltip.innerText + " " + resFAT32LockProfile.innerText
  1471.         chkSharedAccount.Title = resLockProfileTooltip.innerText + " " + resFAT32LockProfile.innerText
  1472.         
  1473.         oRestriction.IsProfileDriveNTFS = False
  1474.     Else
  1475.         spchkSharedAccount.Title = resLockProfileTooltip.innerText 
  1476.         chkSharedAccount.Title = resLockProfileTooltip.innerText 
  1477.     End If
  1478. End Sub
  1479.  
  1480. ' ***
  1481. ' *** ------------------------------------------------------------------------------
  1482. ' *** Name:            HTAUnLoad()
  1483. ' *** ------------------------------------------------------------------------------
  1484. ' *** Purpose:        This method unloads all the objects 
  1485. ' ***            created within the scope of the HTA
  1486. ' *** ------------------------------------------------------------------------------
  1487. ' ***
  1488. Sub HTAUnLoad()
  1489.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1490.     Set oRestriction     = Nothing
  1491.     Set oLog         = Nothing
  1492.     Set oLockPopup        = Nothing
  1493.     Set oRestrictPopup     = Nothing
  1494.     Set oLockAgainPopup    = Nothing
  1495.  
  1496. End Sub
  1497.  
  1498. ' ***
  1499. ' *** ------------------------------------------------------------------------------
  1500. ' *** Name:            DivScroll()
  1501. ' *** ------------------------------------------------------------------------------
  1502. ' *** Purpose:        This method is used to show the popup's for the lock profile
  1503. ' ***            and restrictions checkboxes on scrolling the restrictions
  1504. ' ***           div.
  1505. ' *** ------------------------------------------------------------------------------
  1506. ' ***
  1507. Sub DivScroll()
  1508.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  1509.     oLockPopup.Hide()
  1510.     oRestrictPopup.Hide()
  1511.     oLockAgainPopup.Hide()
  1512. End Sub