home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / free_security / msshared / Shared_Computer_Toolkit_ENU.msi / FileScripts003 < prev    next >
Encoding:
Extensible Markup Language  |  2005-09-02  |  82.7 KB  |  1,139 lines

  1.  ■<?xml version="1.0" ?>
  2. <package>
  3. <comment>
  4. ' ***
  5. ' *** ------------------------------------------------------------------------------
  6. ' *** Filename:        AutoDemo.wsf
  7. ' *** ------------------------------------------------------------------------------
  8. ' *** Description:    Example script that shows how to automatically build a computer 
  9. ' ***            using most of the toolkit tools. Can also be used to quickly
  10. ' ***            build a demo computer running the Toolkit.
  11. ' *** ------------------------------------------------------------------------------
  12. ' *** Prereqs:        Windows XP SP2. WGA Validation must have been completed previously.
  13. ' ***               Disk prerequisites for Windows Disk Protection must be in place.
  14. ' ***            D: drive for the Teenager User Profile. 
  15. ' *** ------------------------------------------------------------------------------
  16. ' *** Version:        1.0
  17. ' *** Notes:        
  18. ' *** ------------------------------------------------------------------------------
  19. ' *** Copyright (C) Microsoft Corporation 2005, All Rights Reserved
  20. ' *** ------------------------------------------------------------------------------
  21. ' ***
  22. </comment>
  23. <job>
  24. <runtime>
  25. <description>AutoDemo</description>
  26. <named name="Uninstall" required="false" many="false" helpstring="Uninstall the Toolkit"/>
  27. <named name="Install" required="false" many="false" helpstring="Install the Toolkit first"/>
  28. <named name="Go"      required="false" many="false" helpstring="Initiate the AutoDemo process"/>
  29. <named name="Cleanup" required="false" many="false" helpstring="Clean up the Demo"/>
  30. <named name="GS2"     required="false" many="false" helpstring="Select/clear the computer settings in Getting Started"/>
  31. <usage>
  32. AutoDemo Usage Instructions
  33. ---------------------------
  34. Options:
  35.     Install   - If this script is placed in a folder with the Toolkit MSI, 
  36.                 this option will install the Toolkit.
  37.     Go        - Start the AutoDemo process. Must be run from and provide
  38.                 the Toolkit admin account and password. Initiates two 
  39.                 restarts and finishes at the logon screen.
  40.     Cleanup   - Remove all of the user profiles and accounts created by /Go.
  41.                 Initiates two restarts.
  42.     GS2       - Select/clear all of the computer settings available in Step 2
  43.                 of Getting Started. If used with /Go, options are selected.
  44.                 If used with /Cleanup, options are cleared.
  45.     ASK       - Ask for confirmation within each created account to allow for
  46.                 manual configuration. Ask to continue after each step.
  47.     Uninstall - If the Toolkit has been installed, this option uninstalls it.
  48. Examples:
  49.     AutoDemo.wsf /Install
  50.     AutoDemo.wsf /Install /Go  toolkitadmin password
  51.     AutoDemo.wsf /Go           toolkitadmin password
  52.     AutoDemo.wsf /Go /GS2      toolkitadmin password
  53.     AutoDemo.wsf /Go /ASK      toolkitadmin password
  54.     AutoDemo.wsf /Go /GS2 /ASK toolkitadmin password
  55.     AutoDemo.wsf /Cleanup      toolkitadmin password
  56.     AutoDemo.wsf /Cleanup /GS2 toolkitadmin password
  57.     AutoDemo.wsf /Uninstall
  58. *******************************************************************************
  59. * Warning: It is highly recommended that you only use this script on a demo   *
  60. * computer.  This script will configure several accounts and perform several  *
  61. * Toolkit functions and computer restarts.                                    *
  62. *******************************************************************************</usage>
  63. </runtime>
  64. <?job error="false" debug="False" ?>
  65. <script language="VBScript">
  66. <![CDATA[
  67. Option Explicit
  68. On Error Resume Next
  69. ' ~~~
  70. ' ~~~ Define localizable variables
  71. ' ~~~
  72. Dim L_AutoDemo_TEXT, L_UsageErrAdm_TEXT, L_UsageErrCreds_TEXT, L_Install_TEXT, L_InstallSuccess_TEXT, L_InstallFail_TEXT
  73. Dim L_Uninstall_TEXT, L_UninstallSuccess_TEXT, L_UninstallFail_TEXT, L_NotCScript_TEXT, L_NoPath_TEXT
  74. Dim L_Cleanup1_TEXT, L_Cleanup1End_TEXT, L_Cleanup2_TEXT, L_Cleanup2End_TEXT, L_Cleanup3_TEXT, L_Cleanup3End_TEXT
  75. Dim L_Step1_TEXT, L_Step1End_TEXT, L_Step2_TEXT, L_Step2a_TEXT, L_Step2b_TEXT, L_Step2End_TEXT, L_Step3_TEXT, L_Step3End_TEXT, L_Step4_TEXT, L_Step4End_TEXT
  76. Dim L_WelcomeList_TEXT, L_WelcomeRemove_TEXT, L_DeleteAcct_TEXT, L_LoggingOff_TEXT, L_Restarting_TEXT, L_SleepWake_TEXT
  77. Dim L_DeleteUP_TEXT, L_AcctCreate_TEXT, L_AcctFail_TEXT, L_WDPInit_TEXT, L_WDPOn_TEXT, L_WDPSave_TEXT, L_WDPOff_TEXT, L_WDPErr_TEXT
  78. Dim L_Accessibility_TEXT, L_AutoRestart_TEXT, L_FinalPwd_TEXT, L_FinalPwdFail_TEXT, L_RunOnceMe_TEXT, L_RunOnceMeFail_TEXT
  79. Dim L_AutoLogon_TEXT, L_AutoLogonDisabled_TEXT, L_LimitAcct_TEXT, L_LimitAcctFail_TEXT, L_UPCreated_TEXT, L_UPCreateFail_TEXT
  80. Dim L_RunOnce_TEXT, L_RunOnceFail_TEXT, L_CheckWDP_TEXT, L_GS2On_TEXT, L_GS2Off_TEXT, L_ASKTitle_TEXT
  81. L_AutoDemo_TEXT         = "AutoDemo"
  82. L_UsageErrAdm_TEXT      = "Warning: AutoDemo must be run from a local administrative account. Cannot continue."
  83. L_UsageErrCreds_TEXT    = "Error: Missing the name and/or password of the Toolkit account. Cannot continue."
  84. L_Install_TEXT          = "Installing "
  85. L_InstallSuccess_TEXT   = "The Shared Computer Toolkit has been successfully installed."
  86. L_InstallFail_TEXT      = "The Shared Computer Toolkit could not be installed -- confirm the prerequisites are in place. Error code: "
  87. L_Uninstall_TEXT        = "Uninstalling Product Code: "
  88. L_UninstallSuccess_TEXT = "The Shared Computer Toolkit has been successfully uninstalled. A restart may    occur automatically if post-uninstall activities are required."
  89. L_UninstallFail_TEXT    = "The Shared Computer Toolkit could not be uninstalled. Error code: "
  90. L_NotCScript_TEXT       = "AutoDemo must be run with CScript, not WScript. To set CScript as the default, type: CScript //H:CScript"
  91. L_NoPath_TEXT           = "AutoDemo cannot determine the path to the Toolkit. Quitting."
  92. L_Cleanup1_TEXT         = "Starting the AutoDemo /Cleanup process..."
  93. L_Cleanup1End_TEXT      = "Continuing to Step2 of the AutoDemo /Cleanup process..."
  94. L_Cleanup2_TEXT         = "AutoDemo /Cleanup Step2..."
  95. L_Cleanup2End_TEXT      = "Continuing to Step3 of the AutoDemo /Cleanup process..."
  96. L_Cleanup3_TEXT         = "AutoDemo /Cleanup Step3..."
  97. L_Cleanup3End_TEXT      = "AutoDemo /Cleanup is now complete."
  98. L_Step1_TEXT            = "Starting the AutoDemo /Go process..."
  99. L_Step1End_TEXT         = "Continuing to Step2 of the AutoDemo process..."
  100. L_Step2_TEXT            = "AutoDemo Step2..."
  101. L_Step2a_TEXT           = "Complete the configuration of "
  102. L_Step2b_TEXT           = " and press OK to continue."
  103. L_Step2End_TEXT         = "Continuing to Step3 of the AutoDemo process..."
  104. L_Step3_TEXT            = "AutoDemo Step3..."
  105. L_Step3End_TEXT         = "Continuing to Step4 of the AutoDemo process..."
  106. L_Step4_TEXT            = "AutoDemo Step4..."
  107. L_Step4End_TEXT         = "AutoDemo is almost complete. Final restart happening now."
  108. L_WelcomeList_TEXT      = "Re-listed the Toolkit administrator account on the Welcome screen."
  109. L_WelcomeRemove_TEXT    = "Removed the Toolkit administrator account from the Welcome screen."
  110. L_DeleteAcct_TEXT       = "Deleted the user account for: "
  111. L_LoggingOff_TEXT       = "Logging off."
  112. L_Restarting_TEXT       = "Restarting the Computer."
  113. L_SleepWake_TEXT        = "Set SleepWakePC options for the computer. Sleep @ " 
  114. L_DeleteUP_TEXT         = "Deleted the user profile for: " 
  115. L_AcctCreate_TEXT       = "Created account: " 
  116. L_AcctFail_TEXT         = "Could not create account: " 
  117. L_WDPInit_TEXT        = "Initializing Windows Disk Protection."
  118. L_WDPOn_TEXT            = "Turning on Windows Disk Protection."
  119. L_WDPSave_TEXT          = "Saving Changes with Windows Disk Protection."
  120. L_WDPOff_TEXT           = "Turning off Windows Disk Protection."
  121. L_WDPErr_TEXT           = "Error: WDP function not called with proper argument."
  122. L_Accessibility_TEXT    = "Set Accessibility options for the current user."
  123. L_AutoRestart_TEXT      = "Set AutoRestart for " 
  124. L_FinalPwd_TEXT         = "Setting final (blank) password for account "
  125. L_FinalPwdFail_TEXT     = "Strong password policy in effect. Could not set final (blank) password for account " 
  126. L_RunOnceMe_TEXT        = "Added RunOnce for the current account to run AutoDemo " 
  127. L_RunOnceMeFail_TEXT    = "Could not add RunOnce for the current account to run AutoDemo " 
  128. L_AutoLogon_TEXT        = "Set computer to AutoLogon as " 
  129. L_AutoLogonDisabled_TEXT = "AutoLogon is now disabled."
  130. L_LimitAcct_TEXT        = "Limited the user account "
  131. L_LimitAcctFail_TEXT    = "Could not limit the user account "
  132. L_UPCreated_TEXT        = " user profile created on drive "
  133. L_UPCreateFail_TEXT     = " user profile could not be created on drive "
  134. L_RunOnce_TEXT          = " RunOnce added for account: "
  135. L_RunOnceFail_TEXT      = " RunOnce could not be added for account: "
  136. L_CheckWDP_TEXT         = "Checking Windows Disk Protection Status."
  137. L_GS2On_TEXT            = "Selecting all of the Computer Options in Getting Started Step 2"
  138. L_GS2Off_TEXT           = "Clearing all of the Computer Options in Getting Started Step 2"
  139. L_ASKTitle_TEXT         = "Click OK to Continue"
  140. ' ~~~ Check that we are running with CScript, not WScript.
  141. If Lcase(Right(Wscript.FullName, 12)) = "\wscript.exe" Then 
  142.     Wscript.Echo L_NotCScript_TEXT
  143.     Quit
  144. End If 
  145. ' ~~~ If no arguments provided, show usage information
  146. If Wscript.Arguments.Count = 0 Then
  147.     WScript.Arguments.Showusage
  148.     Quit
  149. End If
  150. ' ~~~
  151. ' ~~~ Define global variables
  152. ' ~~~
  153. Const TOOLKITKEY = "Software\Microsoft\Shared Computer Toolkit"
  154. Const HKEY_LOCAL_MACHINE = &H80000002
  155. Dim sAppDir, strPath, strIE, strMSI, strPCode, strTempPass, strFinalPass
  156. Dim strUser1, strUser2, strUser3
  157. Dim strDefaultDrive, strDrive1, strDrive2, strDrive3
  158. Dim strRestrict1, strRestrict2, strRestrict3
  159. Dim oShell, oNetwork, oFso, oExec, oAccounts, oGroupAdmins, oGroupUsers, oWMI, oWMIReg, oInstaller
  160. Dim strUser, strPassword, strTemp1, strTemp2, strCMD, nErr
  161. ' ~~~
  162. ' ~~~ MSI and Product Code GUID for Install and Uninstall operations
  163. ' ~~~
  164. strMSI   = "Shared_Computer_Toolkit_ENU.msi"
  165. strPCode = "{BC69E66C-47DE-412E-87DF-D1B8055A9AF7}"
  166. ' ~~~
  167. ' ~~~ The temporary password is the initial password set on the accounts. This password meets many password complexity rules that
  168. ' ~~~ may be required in some domain environments. The password will be changed to the final password later, if it can be.
  169. ' ~~~
  170. strTempPass  = "Password!"
  171. strFinalPass = ""
  172. ' ~~~
  173. ' ~~~ These three sample accounts are created on the computer
  174. ' ~~~
  175. strUser1 = "Teenager"
  176. strUser2 = "Gamer"
  177. strUser3 = "Public"
  178. ' ~~~
  179. ' ~~~ These drive letters represent where each user profile will be created.
  180. ' ~~~
  181. strDefaultDrive = "C"
  182. strDrive1       = "D"
  183. strDrive2       = "C"
  184. strDrive3       = "C"
  185. ' ~~~ If started with the Uninstall argument, uninstall! 
  186. ' ~~~ If we are performing an uninstall as part of cleanup, wait to do the uninstall later.
  187. If WScript.Arguments.Named.Exists("Uninstall") and NOT (WScript.Arguments.Named.Exists("CleanupStep2") or WScript.Arguments.Named.Exists("Cleanup")) Then
  188.     UninstallSCT
  189.     Quit
  190. End If
  191. ' ~~~ If started with the Install argument, initiate the install first.
  192. If WScript.Arguments.Named.Exists("Install") Then
  193.     InstallSCT
  194.     If WScript.Arguments.Unnamed.Count = 0 Then Quit
  195. End If
  196. ' ~~~ Ensure we have a username to continue
  197. If WScript.Arguments.Unnamed.Count < 1 Then
  198.     Wscript.Echo L_UsageErrCreds_TEXT
  199.     Quit
  200. Else
  201.     strUser = Wscript.Arguments.Unnamed.Item(0)
  202. End If
  203. ' ~~~ Establish Shell and WMIReg objects to use below
  204. Set oShell  = CreateObject("WScript.Shell")
  205. Set oWmiReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
  206. ' ~~~
  207. ' ~~~ This is the location of Internet Explorer, which will be AutoRestarted for User .
  208. ' ~~~
  209. strIE = oShell.ExpandEnvironmentStrings("%ProgramFiles%\Internet Explorer\IExplore.exe")
  210. ' ~~~
  211. ' ~~~ This path represents where the Scripts sub-folder of the toolkit install is located.
  212. ' ~~~
  213. oWmiReg.GetStringValue HKEY_LOCAL_MACHINE, TOOLKITKEY, "TargetDir", sAppDir
  214. If sAppDir = "" Then
  215.     WScript.Echo L_NoPath_TEXT
  216.     Quit
  217. End If
  218. strPath = sAppDir & "Scripts\"
  219. ' ~~~
  220. ' ~~~ These files contains the user restrictions applied to each profile.
  221. ' ~~~ Each of these files was created by running User Restrictions.
  222. ' ~~~
  223. strRestrict1 = sAppDir & "xml\AutoDemo.Teenager.xml"
  224. strRestrict2 = sAppDir & "xml\AutoDemo.Gamer.xml"
  225. strRestrict3 = sAppDir & "xml\AutoDemo.Public.xml"
  226. ' ~~~ Establish a couple more of our standard objects - used below
  227. Set oNetwork     = CreateObject("Wscript.Network")
  228. Set oAccounts    = GetObject   ("WinNT://.")
  229. ' ~~~ Ensure we are running from a local admin account to continue
  230. If (oNetwork.ComputerName <> oNetwork.UserDomain) Then
  231.     Wscript.Echo L_UsageErrAdm_TEXT
  232.     Quit
  233. End If
  234. If WScript.Arguments.Unnamed.Count > 1 Then 
  235.     strPassword = Wscript.Arguments.Unnamed.Item(1)
  236. Else
  237.     strPassword = ""
  238. End If
  239. If WScript.Arguments.Named.Exists("Cleanup") Then
  240.     Wscript.Echo L_Cleanup1_TEXT
  241.     WScript.Echo ""
  242.     ' ~~~ Get ready to AutoLogon and continue when this step is done
  243.     AutoLogon strUser, strPassword
  244.     ' ~~~ If doing a uninstall after the cleanup, pass the argument on
  245.     If WScript.Arguments.Named.Exists("Uninstall") Then
  246.         AutoRunOnceMe "/CleanupStep2 /Uninstall"
  247.     Else
  248.         AutoRunOnceMe "/CleanupStep2"
  249.     End If
  250.     WScript.Echo ""
  251.     ' ~~~ Clean up user profiles
  252.     DeleteUserProfile strUser1
  253.     DeleteUserProfile strUser2
  254.     DeleteUserProfile strUser3
  255.     WScript.Echo ""
  256.     ' ~~~ Clean up user accounts
  257.     DeleteUser strUser1
  258.     DeleteUser strUser2
  259.     DeleteUser strUser3
  260.     WScript.Echo ""
  261.     ' ~~~ Turn off Getting Started Step 2 checkboxes
  262.     If WScript.Arguments.Named.Exists("GS2") Then HKLM False
  263.     ' ~~~ Commit Changes with Windows Disk Protection
  264.     WDP "Save"
  265.     ' ~~~ Restart the computer and return to the next step below
  266.     If WScript.Arguments.Named.Exists("ASK") Then MsgBox L_Cleanup1End_TEXT, vbInformation, L_ASKTitle_TEXT
  267.     Restart L_Cleanup1End_TEXT
  268.     Quit
  269. End If
  270. If WScript.Arguments.Named.Exists("CleanupStep2") Then
  271.     ' ~~~ If we are coming into this step and WDP is already off, then it means it is the second time here (i.e. CleanupStep3).
  272.     ' ~~~ Check WDP Status
  273.     WScript.Echo L_CheckWDP_TEXT
  274.     WScript.Echo ""
  275.     
  276.     ' Run WDP.cmd as tool #5
  277.     Call oShell.Run(Chr(34) & sAppDir & "bin\WDP.CMD" & Chr(34) & " 5", 0, True)
  278.     Set oFso = CreateObject("Scripting.FileSystemObject")
  279.     If oFso.GetFile(oShell.ExpandEnvironmentStrings("%WinDir%\system32\Enabled5.wdp")).size <> 0 Then 
  280.         ' ~~~ Windows Disk Protection is on, so turn it off
  281.         Wscript.Echo L_Cleanup2_TEXT
  282.         WScript.Echo ""
  283.         ' ~~~ Turn off Windows Disk Protection
  284.         WDP "Off"
  285.         If WScript.Arguments.Named.Exists("ASK") Then MsgBox L_Cleanup2End_TEXT, vbInformation, L_ASKTitle_TEXT
  286.         Restart L_Cleanup2End_TEXT
  287.         WScript.Sleep 5000
  288.         ' ~~~ Note that we don't have to set RunOnce again, because turning off Windows Disk Protection will cause the computer to
  289.         ' ~~~ roll back to when disk changes were last saved (when RunOnce was configured to occur).
  290.     Else
  291.         ' ~~~ Windows Disk Protection is off, so finish AutoDemo
  292.         Wscript.Echo L_Cleanup3_TEXT
  293.         WScript.Echo ""
  294.         AutoLogonDisable
  295.         ' ~~~ If uninstall argument also provided, uninstall the Toolkit now
  296.         If WScript.Arguments.Named.Exists("UnInstall") Then
  297.             UninstallSCT
  298.         End If
  299.         WScript.Echo L_Cleanup3End_TEXT
  300.         MsgBox L_Cleanup3End_TEXT, vbInformation, L_AutoDemo_TEXT
  301.     End If
  302.     ' ~~~ Delete the temporary files created by WDP.cmd
  303.     oFso.DeleteFile(oshell.ExpandEnvironmentStrings("%WinDir%") & "\system32\Temp5.wdp")
  304.     oFso.DeleteFile(oshell.ExpandEnvironmentStrings("%WinDir%") & "\system32\Enabled5.wdp")
  305.     oFso.DeleteFile(oshell.ExpandEnvironmentStrings("%WinDir%") & "\system32\Overlay5.wdp")
  306.     oFso.DeleteFile(oshell.ExpandEnvironmentStrings("%WinDir%") & "\system32\Undo5.wdp")
  307.     oFso.DeleteFile(oshell.ExpandEnvironmentStrings("%WinDir%") & "\system32\Commit5.wdp")
  308.     oFso.DeleteFile(oshell.ExpandEnvironmentStrings("%WinDir%") & "\system32\Retain5.wdp")
  309.     oFso.DeleteFile(oshell.ExpandEnvironmentStrings("%WinDir%") & "\system32\Enable5.wdp")
  310.     oFso.DeleteFile(oshell.ExpandEnvironmentStrings("%WinDir%") & "\system32\Disable5.wdp")
  311.     Quit
  312. End If
  313. ' ~~~ Establish the rest of our standard objects - as required by /Go and /StepX
  314. ' ~~~ These WMI and Group objects are not required by the Install and Cleanup steps above
  315. Set oWMI         = GetObject   ("winmgmts:\\.\root\cimv2")
  316. Set oGroupAdmins = GetObject   ("WinNT://./" & GetGroupName("S-1-5-32-544") & ",group")
  317. Set oGroupUsers  = GetObject   ("WinNT://./" & GetGroupName("S-1-5-32-545") & ",group")
  318. If WScript.Arguments.Named.Exists("Go") Then
  319.     Wscript.Echo L_Step1_TEXT
  320.     WScript.Echo ""
  321.     If WScript.Arguments.Named.Exists("GS2") Then HKLM True
  322.     ' ~~~ First let's create all of our users as admin
  323.     AddUser strUser1, strTempPass
  324.     AddUser strUser2, strTempPass
  325.     AddUser strUser3, strTempPass
  326.     WScript.Echo ""
  327.     ' ~~~ Now let's create all of the profiles
  328.     CreateUserProfile strUser1, strTempPass, strDrive1
  329.     CreateUserProfile strUser2, strTempPass, strDrive2
  330.     CreateUserProfile strUser3, strTempPass, strDrive3 
  331.     WScript.Echo ""
  332.     ' ~~~ Then let's Set up the RunOnce details for each profile so they run this script at the next step
  333.     AutoRunOnce "/Step2", strUser1
  334.     AutoRunOnce "/Step2", strUser2 
  335.     AutoRunOnce "/Step2", strUser3 
  336.     WScript.Echo ""
  337.     AutoRunOnceMe "/Step3"
  338.     WScript.Echo ""
  339.     ' ~~~ Then let's Set this computer to autologon as the first account
  340.     AutoLogon strUser1, strTempPass
  341.     If WScript.Arguments.Named.Exists("ASK") Then MsgBox L_Step1End_TEXT, vbInformation, L_ASKTitle_TEXT
  342.     Logoff
  343.     Wscript.Echo L_Step1End_TEXT
  344.     WScript.Sleep 5000
  345.     Quit
  346. End If
  347. If Wscript.Arguments.Named.Exists("Step2") Then
  348.     Wscript.Echo L_Step2_TEXT
  349.     WScript.Echo ""
  350.     ' ~~~ Now set the computer to autologon as the next account, and finally as the Toolkit admin
  351.     Select Case oNetwork.UserName
  352.         Case strUser1 
  353.             AutoLogon strUser2, strTempPass
  354.             If WScript.Arguments.Named.Exists("ASK") Then 
  355.                 WScript.Echo L_Step2End_TEXT & strUser1
  356.                 MsgBox L_Step2a_TEXT & strUser1 & L_Step2b_TEXT, vbInformation, L_ASKTitle_TEXT
  357.             End If
  358.         Case strUser2 
  359.             AutoLogon strUser3, strTempPass
  360.             If WScript.Arguments.Named.Exists("ASK") Then 
  361.                 WScript.Echo L_Step2End_TEXT & strUser2
  362.                 MsgBox L_Step2a_TEXT & strUser2 & L_Step2b_TEXT, vbInformation, L_ASKTitle_TEXT
  363.             End If
  364.         Case strUser3 
  365.             AutoLogon strUser, strPassword
  366.             ' ~~~ Set up strUser3 (Public) with Accessibility options
  367.             Accessibility "/LargePointer"
  368.             If WScript.Arguments.Named.Exists("ASK") Then 
  369.                 WScript.Echo L_Step2a_TEXT & strUser3
  370.                 MsgBox L_Step2a_TEXT & strUser3 & L_Step2b_TEXT, vbInformation, L_ASKTitle_TEXT
  371.             End If
  372.             Wscript.Echo L_Step2End_TEXT 
  373.     End Select
  374.     Logoff
  375.     WScript.Sleep 5000
  376.     Quit
  377. End If
  378. If Wscript.Arguments.Named.Exists("Step3") Then
  379.     Wscript.Echo L_Step3_TEXT
  380.     WScript.Echo ""
  381.     ' ~~~ Now let's take care of business as the Toolkit administrator again.
  382.     ' ~~~ First, ensure that the process continues after the restart below.
  383.     AutoRunOnceMe("/Step4")
  384.     ' ~~~ Now convert the users to limited users
  385.     MakeLimitedUser strUser1
  386.     MakeLimitedUser strUser2
  387.     MakeLimitedUser strUser3
  388.     WScript.Echo ""
  389.     ' ~~~ Now set their final passwords (if the computer allows this due to password policy)
  390.     SetFinalPassword strUser1, strFinalPass
  391.     SetFinalPassword strUser2, strFinalPass
  392.     SetFinalPassword strUser3, strFinalPass
  393.     WScript.Echo ""
  394.     ' ~~~ Run DiskProtect without command-line parameters to initialize
  395.     WDP "Init"
  396.     If WScript.Arguments.Named.Exists("ASK") Then MsgBox L_Step3End_TEXT, vbInformation, L_ASKTitle_TEXT
  397.     ' ~~~ Let's Restart the computer so we can come back and do Disk Protection
  398.     Restart L_Step3End_TEXT
  399.     WScript.Sleep 5000
  400.     Quit
  401. End If
  402. If Wscript.Arguments.Named.Exists("Step4") Then
  403.     Wscript.Echo L_Step4_TEXT
  404.     WScript.Echo ""
  405.     ' ~~~ This is the last step... so turn off AutoLogon
  406.     AutoLogonDisable
  407.     ' ~~~ Set up strUser2 (Gamer) to AutoRestart IE
  408.     AutoRestart strUser2, strIE
  409.     ' ~~~ Now let's restrict each of the accounts
  410.     RestrictUser strUser1, strRestrict1
  411.     RestrictUser strUser2, strRestrict2
  412.     RestrictUser strUser3, strRestrict3
  413.     WScript.Echo ""
  414.     ' ~~~ And Turn on Windows Disk Protection
  415.     WDP "On"
  416.     ' ~~~ And Configure the computer to automatically Sleep, then Wake for WDP critical updates - but only if interactive since SleepWake requires manual steps
  417.     If WScript.Arguments.Named.Exists("ASK") Then SleepWake "18:30"
  418.     If WScript.Arguments.Named.Exists("ASK") Then MsgBox L_Step4End_TEXT, vbInformation, L_ASKTitle_TEXT
  419.     ' ~~~ Finally, let's restart the computer to make WDP take effect
  420.     Restart L_Step4End_TEXT
  421.     WScript.Sleep 5000
  422.     Quit
  423. End If
  424. ' ***
  425. ' *** --------------------------------------------------------------------------------
  426. ' *** Name:         InstallSCT()
  427. ' *** --------------------------------------------------------------------------------
  428. ' *** Purpose:         Install the Toolkit if AutoDemo is in the same directory
  429. ' ***            as the MSI.
  430. ' *** --------------------------------------------------------------------------------
  431. ' ***
  432. Sub InstallSCT()
  433.     On Error Resume Next
  434.     Wscript.Echo L_Install_TEXT & strMSI
  435.     WScript.Echo ""
  436.     Set oInstaller = CreateObject("WindowsInstaller.Installer")
  437.     oInstaller.UILevel = 4
  438.     oInstaller.InstallProduct strMSI, "ACTION=INSTALL"
  439.     nErr = oInstaller.ProductState(strPCode)
  440.     Set oInstaller = Nothing
  441.     If nErr = 5 Then
  442.         WScript.Echo L_InstallSuccess_TEXT
  443.         WScript.Echo ""
  444.     Else
  445.         Wscript.Echo L_InstallFail_TEXT & nErr
  446.         Quit
  447.     End If
  448. End Sub
  449. ' ***
  450. ' *** --------------------------------------------------------------------------------
  451. ' *** Name:         UninstallSCT()
  452. ' *** --------------------------------------------------------------------------------
  453. ' *** Purpose:         Uninstall the Toolkit.
  454. ' *** --------------------------------------------------------------------------------
  455. ' ***
  456. Sub UninstallSCT()
  457.     On Error Resume Next
  458.     Wscript.Echo L_Uninstall_TEXT & strPCode
  459.     WScript.Echo ""
  460.     Set oInstaller = CreateObject("WindowsInstaller.Installer")
  461.     oInstaller.UILevel = 3
  462.     oInstaller.ConfigureProduct strPCode, 0, 2
  463.     nErr = oInstaller.ProductState(strPCode)
  464.     Set oInstaller = Nothing
  465.     If nErr = -1 Then
  466.         WScript.Echo L_UninstallSuccess_TEXT
  467.     Else
  468.         Wscript.Echo L_UninstallFail_TEXT & nErr
  469.     End If
  470. End Sub
  471. ' ***
  472. ' *** --------------------------------------------------------------------------------
  473. ' *** Name:         AddUser(strNewUser, strNewPassword)
  474. ' *** --------------------------------------------------------------------------------
  475. ' *** Purpose:         Add a local user account, set the initial password, and add
  476. ' ***            it to the administrators group.
  477. ' *** --------------------------------------------------------------------------------
  478. ' ***
  479. Function AddUser(strNewUser, strNewPassword)
  480.     ' ~~~ We need to catch errors in this routine
  481.     On Error Resume Next
  482.     Dim oUser
  483.     AddUser = True
  484.     ' ~~~ Create the User
  485.     Set oUser = oAccounts.Create("User", strNewUser)
  486.     If Err.Number <> 0 Then AddUser = False
  487.     oUser.SetPassword strNewPassword
  488.     oUser.SetInfo
  489.     If Err.Number <> 0 Then AddUser = False
  490.     ' ~~~ Add them to the Administrators group
  491.     oGroupAdmins.Add "WinNT://" & oNetwork.ComputerName & "/" & strNewUser
  492.     If Err.Number <> 0 Then AddUser = False
  493.     If AddUser Then
  494.         Wscript.Echo L_AcctCreate_TEXT & strNewUser
  495.     Else
  496.         Wscript.Echo L_AcctFail_TEXT & strNewUser
  497.         WScript.Sleep 5000
  498.     End If
  499.     Set oUser = Nothing
  500. End Function
  501. ' ***
  502. ' *** --------------------------------------------------------------------------------
  503. ' *** Name:         CheckDrive(strLoc)
  504. ' *** --------------------------------------------------------------------------------
  505. ' *** Purpose:         Check that the drive is ready and the right type for a profile
  506. ' *** --------------------------------------------------------------------------------
  507. ' ***
  508. Function CheckDrive(strLoc)
  509.     CheckDrive = False
  510.     Dim dDrive, oFso
  511.     Set oFso = CreateObject("Scripting.FileSystemObject")
  512.     ' ~~~ We need to catch errors in this routine
  513.     On Error Resume Next
  514.     Set dDrive = oFso.GetDrive(strLoc)
  515.     If Err.number <> 0 Then Exit Function
  516.     If dDrive.IsReady and dDrive.DriveType = 2 Then CheckDrive = True
  517.     Set dDrive = Nothing
  518.     Set oFso   = Nothing
  519. End Function
  520. ' ***
  521. ' *** --------------------------------------------------------------------------------
  522. ' *** Name:         CreateUserProfile(strNewUser, strNewPassword, strLoc)
  523. ' *** --------------------------------------------------------------------------------
  524. ' *** Purpose:         Create the initial user profile for a new local account
  525. ' *** --------------------------------------------------------------------------------
  526. ' ***
  527. Function CreateUserProfile(strNewUser, strNewPassword, strLoc)
  528.     CreateUserProfile = False
  529.     strCMD = ""
  530.     strCMD         = Chr(34) & strPath & "ProfileMgr.wsf" & Chr(34) & " /Create " & strNewUser & " " & strNewPassword & " /Drive:" & strLoc
  531.     If strLoc <> strDefaultDrive Then 
  532.         If NOT CheckDrive(strLoc) Then
  533.             strCMD = Chr(34) & strPath & "ProfileMgr.wsf" & Chr(34) & " /Create " & strNewUser & " " & strNewPassword
  534.         End If
  535.     End If
  536.     WScript.Echo strCMD
  537.     WSCript.Echo ""
  538.     ' ~~~ We need to catch errors in this routine
  539.     On Error Resume Next
  540.     oShell.Run strCMD, 7, True
  541.     If Err.Number = 0 Then CreateUserProfile = True
  542.     If CreateUserProfile Then 
  543.         Wscript.Echo strNewUser & L_UPCreated_TEXT & strLoc
  544.     Else
  545.         Wscript.Echo strNewUser & L_UPCreateFail_TEXT & strLoc
  546.     End If
  547.     WSCript.Echo ""
  548. End Function
  549. ' ***
  550. ' *** --------------------------------------------------------------------------------
  551. ' *** Name:         AutoRunOnce(strStep, strUserMod)
  552. ' *** --------------------------------------------------------------------------------
  553. ' *** Purpose:         Ensure AutoDemo is started again from each account
  554. ' *** --------------------------------------------------------------------------------
  555. ' ***
  556. Function AutoRunOnce(strStep, strUserMod)
  557.     ' ~~~ We need to catch errors in this routine
  558.     On Error Resume Next
  559.     AutoRunOnce = False
  560.     strCMD = ""
  561.     If WScript.Arguments.Named.Exists("ASK") Then
  562.         strCMD = Chr(34) & strPath & "AutoRunOnce.wsf" & Chr(34) & " /Add:SCTKey " & Chr(34) & strPath & "AutoDemo.wsf" & Chr(34) & " /args:" & Chr(34) & "/ASK " & strStep & " " & strUser & " " & strPassword & Chr(34) & " /user:" & strUserMod
  563.     Else
  564.         strCMD = Chr(34) & strPath & "AutoRunOnce.wsf" & Chr(34) & " /Add:SCTKey " & Chr(34) & strPath & "AutoDemo.wsf" & Chr(34) & " /args:" & Chr(34)           & strStep & " " & strUser & " " & strPassword & Chr(34) & " /user:" & strUserMod
  565.     End If
  566.     WScript.Echo strCMD
  567.     WScript.Echo ""
  568.     oShell.Run strCMD, 7, True
  569.     If Err.Number = 0 Then AutoRunOnce = True
  570.     If AutoRunOnce Then 
  571.         Wscript.Echo L_AutoDemo_TEXT & strStep & L_RunOnce_TEXT & strUserMod
  572.     Else
  573.         Wscript.Echo L_AutoDemo_TEXT & strStep & L_RunOnceFail_TEXT & strUserMod
  574.         WScript.Sleep 5000
  575.     End If
  576.     WSCript.Echo ""
  577. End Function
  578. ' ***
  579. ' *** --------------------------------------------------------------------------------
  580. ' *** Name:         AutoRunOnceMe(strStep)
  581. ' *** --------------------------------------------------------------------------------
  582. ' *** Purpose:         Ensure AutoDemo is started again from this account
  583. ' *** --------------------------------------------------------------------------------
  584. ' ***
  585. Function AutoRunOnceMe(strStep)
  586.     ' ~~~ We need to catch errors in this routine
  587.     On Error Resume Next
  588.     AutoRunOnceMe = False
  589.     strCMD = ""
  590.     If WScript.Arguments.Named.Exists("ASK") Then
  591.         strCMD = Chr(34) & strPath & "AutoRunOnce.wsf" & Chr(34) & " /Add:SCTKey " & Chr(34) & strPath & "AutoDemo.wsf" & Chr(34) & " /args:" & Chr(34) & "/ASK " & strStep & " " & strUser & " " & strPassword & Chr(34)
  592.     Else
  593.         strCMD = Chr(34) & strPath & "AutoRunOnce.wsf" & Chr(34) & " /Add:SCTKey " & Chr(34) & strPath & "AutoDemo.wsf" & Chr(34) & " /args:" & Chr(34)           & strStep & " " & strUser & " " & strPassword & Chr(34)
  594.     End If
  595.     WScript.Echo strCMD
  596.     WScript.Echo ""
  597.     oShell.Run strCMD, 7, True
  598.     If Err.Number = 0 Then AutoRunOnceMe = True
  599.     If AutoRunOnceMe Then 
  600.         Wscript.Echo L_RunOnceMe_TEXT & strStep
  601.     Else
  602.         Wscript.Echo L_RunOnceMeFail_TEXT & strStep
  603.         WScript.Sleep 5000
  604.     End If
  605.     WSCript.Echo ""
  606. End Function
  607. ' ***
  608. ' *** --------------------------------------------------------------------------------
  609. ' *** Name:         SetFinalPassword(strUserMod, strFinalPassword)
  610. ' *** --------------------------------------------------------------------------------
  611. ' *** Purpose:         Change the initial complex password to the final password.
  612. ' ***             This is used to make the password blank, if possible
  613. ' *** --------------------------------------------------------------------------------
  614. ' ***
  615. Sub SetFinalPassword(strUserMod, strFinalPassword)
  616.     ' ~~~ We need to catch errors in this routine
  617.     On Error Resume Next
  618.     Dim oUser
  619.     Set oUser = GetObject("WinNT://./" & strUserMod & ",user")
  620.     oUser.SetPassword strFinalPassword
  621.     oUser.SetInfo
  622.     If Err.Number = 0 Then
  623.         WScript.Echo L_FinalPwd_TEXT & strUserMod
  624.     Else
  625.         WScript.Echo L_FinalPwdFail_TEXT & strUserMod
  626.         WScript.Sleep 1000
  627.     End If
  628. End Sub
  629. ' ***
  630. ' *** --------------------------------------------------------------------------------
  631. ' *** Name:         MakeLimitedUser(strUserMod)
  632. ' *** --------------------------------------------------------------------------------
  633. ' *** Purpose:         Remove an account from the administrators group and add it
  634. ' ***             to the users group.
  635. ' *** --------------------------------------------------------------------------------
  636. ' ***
  637. Function MakeLimitedUser(strUserMod)
  638.     ' ~~~ We need to catch errors in this routine
  639.     On Error Resume Next
  640.     MakeLimitedUser = False
  641.     oGroupAdmins.Remove "WinNT://" & oNetwork.ComputerName & "/" & strUserMod
  642.     oGroupUsers.Add     "WinNT://" & oNetwork.ComputerName & "/" & strUserMod
  643.     If Err.Number = 0 Then MakeLimitedUser = True
  644.     If MakeLimitedUser Then
  645.         Wscript.Echo L_LimitAcct_TEXT & strUserMod
  646.     Else
  647.         Wscript.Echo L_LimitAcctFail_TEXT & strUserMod
  648.         WScript.Sleep 5000
  649.     End If
  650. End Function
  651. ' ***
  652. ' *** --------------------------------------------------------------------------------
  653. ' *** Name:         AutoLogon(strUserMod, strPasswordMod)
  654. ' *** --------------------------------------------------------------------------------
  655. ' *** Purpose:         Establish an account to AutoLogon... so AutoDemo can begin
  656. ' ***             again after a restart or logoff.
  657. ' *** --------------------------------------------------------------------------------
  658. ' ***
  659. Sub AutoLogon(strUserMod, strPasswordMod)
  660.     strCMD = ""
  661.     strCMD = Chr(34) & strPath & "AutoLogon.wsf" & Chr(34) & " /Enable " & strUserMod & " " & strPasswordMod
  662.     WScript.Echo strCMD
  663.     WScript.Echo ""
  664.     oShell.Run strCMD, 7, True
  665.     Wscript.Echo L_AutoLogon_TEXT & strUserMod
  666.     WScript.Echo ""
  667. End Sub
  668. ' ***
  669. ' *** --------------------------------------------------------------------------------
  670. ' *** Name:         AutoLogonDisable
  671. ' *** --------------------------------------------------------------------------------
  672. ' *** Purpose:         Turn off AutoLogon
  673. ' *** --------------------------------------------------------------------------------
  674. ' ***
  675. Sub AutoLogonDisable
  676.     strCMD = ""
  677.     strCMD = Chr(34) & strPath & "AutoLogon.wsf" & Chr(34) & " /Disable"
  678.     WScript.Echo strCMD
  679.     WScript.Echo ""
  680.     oShell.Run strCMD, 7, True
  681.     Wscript.Echo L_AutoLogonDisabled_TEXT
  682.     WScript.Echo ""
  683. End Sub
  684. ' ***
  685. ' *** --------------------------------------------------------------------------------
  686. ' *** Name:         AutoRestart(strUserMod, strPgm)
  687. ' *** --------------------------------------------------------------------------------
  688. ' *** Purpose:         Cause an application to automtically start and restart
  689. ' ***             within a specific user profile.
  690. ' *** --------------------------------------------------------------------------------
  691. ' ***
  692. Sub AutoRestart(strUserMod, strPgm)
  693.     strCMD = ""
  694.     strCMD = Chr(34) & strPath & "AutoRestart.wsf" & Chr(34) & " /Enable " & strUserMod & " " & Chr(34) & strPgm & Chr(34)
  695.     WScript.Echo strCMD
  696.     WScript.Echo ""
  697.     oShell.Run strCMD, 7, True
  698.     Wscript.Echo L_AutoRestart_TEXT & strUserMod & ", " & strPgm
  699.     WScript.Echo ""
  700. End Sub
  701. ' ***
  702. ' *** --------------------------------------------------------------------------------
  703. ' *** Name:         Accessibility(strParms)
  704. ' *** --------------------------------------------------------------------------------
  705. ' *** Purpose:         Set some accesssibility options within a profile.
  706. ' *** --------------------------------------------------------------------------------
  707. ' ***
  708. Sub Accessibility(strParms)
  709.     strCMD = ""
  710.     strCMD = Chr(34) & strPath & "Accessibility.wsf" & Chr(34) & " " & strParms
  711.     WScript.Echo strCMD
  712.     WScript.Echo ""
  713.     oShell.Run strCMD, 7, True
  714.     Wscript.Echo L_Accessibility_TEXT
  715.     WScript.Echo ""
  716.     Wscript.Sleep 5000
  717. End Sub
  718. ' ***
  719. ' *** --------------------------------------------------------------------------------
  720. ' *** Name:         HKLM(bOn)
  721. ' *** --------------------------------------------------------------------------------
  722. ' *** Purpose:         Set/unset the security settings from Getting Started Step 2.
  723. ' *** --------------------------------------------------------------------------------
  724. ' ***
  725. Sub HKLM(bOn)
  726.     Const WELCOMELOGONKEY        = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\LogonType"             
  727.     ' ~~~ WelcomeLogonKey      = 0: Classic CAD Mode, 1: Welcome Screen
  728.     
  729.     Const WELCOMEOFFCOMPKEY1   = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\ShutdownWithoutLogon"    
  730.     ' ~~~ WelcomeOffCompKEY1   = 0: Disable Turn off Computer, 1: Enable Turn off Computer (default)
  731.     
  732.     Const WELCOMEOFFCOMPKEY2   = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\shutdownwithoutlogon"    
  733.     ' ~~~ WelcomeOffCompKEY2   = 0: Disable Shutdown, 1: Enable Shutdown (default)
  734.     
  735.     Const LASTLOGONKEY        = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system\dontdisplaylastusername" 
  736.     ' ~~~ LastLogonKEY         = 0: Display last username (default), 1: Don't display last username
  737.     
  738.     CONST NOLMHASHKEY       = "HKLM\SYSTEM\CurrentControlSet\Control\Lsa\NoLMHash"
  739.     ' ~~~ NoLMHashKEY       = 0: LMHash used (default), 1: Don't store passwords using LMHash
  740.     
  741.     Const NOACCTCACHEKEY        = "HKLM\SYSTEM\CurrentControlSet\Control\Lsa\DisableDomainCreds"                     
  742.     ' ~~~ NoAcctCacheKEY       = 0: Enable storage (default), 1: Disable storage
  743.     
  744.     Const DELROAMINGCACHEKEY   = "HKLM\SOFTWARE\Policies\Microsoft\Windows\System\DeleteRoamingCache"                
  745.     ' ~~~ DelRoamingCacheKEY   = 0: Do not delete roaming profiles (default), 1: Delete them
  746.     
  747.     Const PROFILEERRACTIONKEY  = "HKLM\SOFTWARE\Policies\Microsoft\Windows\System\ProfileErrorAction"                
  748.     ' ~~~ ProfileErrActionKEY  = 0: Allow logon without roaming profile (default), 1: Don't allow this
  749.     Dim x, y
  750.     If bOn Then
  751.         Wscript.Echo L_GS2On_TEXT
  752.         x = 1
  753.         y = 0
  754.     Else
  755.         Wscript.Echo L_GS2Off_TEXT
  756.         x = 0
  757.         y = 1
  758.     End If
  759.     WScript.Echo ""
  760.     oShell.RegWrite WELCOMELOGONKEY,     x, "REG_DWORD"
  761.     oShell.RegWrite WELCOMEOFFCOMPKEY1,  y, "REG_DWORD"
  762.     oShell.RegWrite WELCOMEOFFCOMPKEY2,  y, "REG_DWORD"
  763.     oShell.RegWrite LASTLOGONKEY,        x, "REG_DWORD"
  764.     oShell.RegWrite NOLMHASHKEY,         x, "REG_DWORD"
  765.     oShell.RegWrite NOACCTCACHEKEY,      x, "REG_DWORD"
  766.     oShell.RegWrite DELROAMINGCACHEKEY,  x, "REG_DWORD"
  767.     oShell.RegWrite PROFILEERRACTIONKEY, x, "REG_DWORD"
  768.     strCMD = ""
  769.     If NOT bOn Then
  770.         strCMD = Chr(34) & strPath & "Welcome.wsf" & Chr(34) & " /Enable " & strUser
  771.     Else
  772.         strCMD = Chr(34) & strPath & "Welcome.wsf" & Chr(34) & " /Disable " & strUser
  773.     End If
  774.     WScript.Echo strCMD
  775.     WScript.Echo ""
  776.     oShell.Run strCMD, 7, True
  777.     If NOT bOn Then
  778.         Wscript.Echo L_WelcomeList_TEXT
  779.     Else
  780.         Wscript.Echo L_WelcomeRemove_TEXT
  781.     End If
  782.     WScript.Echo ""
  783. End Sub
  784. ' ***
  785. ' *** --------------------------------------------------------------------------------
  786. ' *** Name:         RestrictUser(strUserMod, strRestrict)
  787. ' *** --------------------------------------------------------------------------------
  788. ' *** Purpose:         Restrict and lock a user profile.
  789. ' *** --------------------------------------------------------------------------------
  790. ' ***
  791. Sub RestrictUser(strUserMod, strRestrict)
  792.     Wscript.Echo "Restrict user profile: " & strUserMod
  793.     strCMD = ""
  794.     strCMD = Chr(34) & strPath & "Restrict.wsf" & Chr(34) & " /apply /user:" & strUserMod & " /xml:" & Chr(34) & strRestrict & Chr(34)
  795.     WScript.Echo strCMD
  796.     WScript.Echo ""
  797.     oShell.Run strCMD, 7, True
  798. End Sub
  799. ' ***
  800. ' *** --------------------------------------------------------------------------------
  801. ' *** Name:         WDP(strSetting)
  802. ' *** --------------------------------------------------------------------------------
  803. ' *** Purpose:         Change Windows Disk Protection
  804. ' *** --------------------------------------------------------------------------------
  805. ' ***
  806. Sub WDP(strSetting)
  807.     strCMD = ""
  808.     Select Case strSetting
  809.         Case "Init"
  810.             Wscript.Echo L_WDPInit_TEXT
  811.             strCMD = Chr(34) & strPath & "DiskProtect.wsf" & Chr(34)
  812.         Case "On"
  813.             Wscript.Echo L_WDPOn_TEXT
  814.             strCMD = Chr(34) & strPath & "DiskProtect.wsf" & Chr(34) & " /On /MU /Time:03"
  815.         Case "Save"
  816.             Wscript.Echo L_WDPSave_TEXT
  817.             strCMD = Chr(34) & strPath & "DiskProtect.wsf" & Chr(34) & " /Save"
  818.         Case "Off"
  819.             Wscript.Echo L_WDPOff_TEXT
  820.             strCMD = Chr(34) & strPath & "DiskProtect.wsf" & Chr(34) & " /Off"
  821.         Case Else
  822.             Wscript.Echo L_WDPErr_TEXT
  823.             WScript.Sleep 5000
  824.             Quit
  825.     End Select
  826.     WScript.Echo strCMD
  827.     WScript.Echo ""
  828.     oShell.Run strCMD, 7, True
  829. End Sub
  830. ' ***
  831. ' *** --------------------------------------------------------------------------------
  832. ' *** Name:         SleepWake(strTime)
  833. ' *** --------------------------------------------------------------------------------
  834. ' *** Purpose:         Start the SleepWake command-line tool
  835. ' *** --------------------------------------------------------------------------------
  836. ' ***
  837. Sub SleepWake(strTime)
  838.     strCMD = ""
  839.     strCMD = Chr(34) & strPath & "SleepWakePC.wsf" & Chr(34) & " /Wake /Sleep:" & strTime & " /User:" & strUser & " /Password:" & strPassword
  840.     WScript.Echo strCMD
  841.     WScript.Echo ""
  842.     oShell.Run strCMD, 7, True
  843.     WScript.Echo L_SleepWake_TEXT & strTime
  844.     WScript.Echo ""
  845. End Sub
  846. ' ***
  847. ' *** --------------------------------------------------------------------------------
  848. ' *** Name:         DeleteUserProfile(strUser)
  849. ' *** --------------------------------------------------------------------------------
  850. ' *** Purpose:         Delete a user profile
  851. ' *** --------------------------------------------------------------------------------
  852. ' ***
  853. Sub DeleteUserProfile(strUser)
  854.     strCMD = ""
  855.     strCMD = Chr(34) & strPath & "ProfileMgr.wsf" & Chr(34) & " /Delete " & strUser
  856.     WScript.Echo strCMD
  857.     WScript.Echo ""
  858.     oShell.Run strCMD, 7, True
  859.     Wscript.Echo L_DeleteUP_TEXT & strUser
  860.     WScript.Echo ""
  861. End Sub
  862. ' ***
  863. ' *** --------------------------------------------------------------------------------
  864. ' *** Name:         DeleteUser(strUser)
  865. ' *** --------------------------------------------------------------------------------
  866. ' *** Purpose:         Delete a user account
  867. ' *** --------------------------------------------------------------------------------
  868. ' ***
  869. Sub DeleteUser(strUser)
  870.     ' ~~~ We need to ignore errors in this routine
  871.     On Error Resume Next
  872.     Wscript.Echo L_DeleteAcct_TEXT & strUser
  873.     oAccounts.Delete "user", strUser
  874. End Sub
  875. ' ***
  876. ' *** --------------------------------------------------------------------------------
  877. ' *** Name:         Logoff
  878. ' *** --------------------------------------------------------------------------------
  879. ' *** Purpose:         Logoff the current account
  880. ' *** --------------------------------------------------------------------------------
  881. ' ***
  882. Sub Logoff
  883.     Wscript.Echo L_LoggingOff_TEXT
  884.     WScript.Echo ""
  885.     oShell.Run "Shutdown.exe -l -f -t 05", 7, True
  886. End Sub
  887. ' ***
  888. ' *** --------------------------------------------------------------------------------
  889. ' *** Name:         Restart(strComment)
  890. ' *** --------------------------------------------------------------------------------
  891. ' *** Purpose:         Restart the computer with a message
  892. ' *** --------------------------------------------------------------------------------
  893. ' ***
  894. Sub Restart(strComment)
  895.     Wscript.Echo L_Restarting_TEXT
  896.     WScript.Echo ""
  897.     oShell.Run "Shutdown.exe -r -f -t 05 -c " & Chr(34) & strComment & Chr(34), 7, True
  898. End Sub
  899. ' ***
  900. ' *** --------------------------------------------------------------------------------
  901. ' *** Name:         GetGroupName(strSID)
  902. ' *** --------------------------------------------------------------------------------
  903. ' *** Purpose:        Returns the group name for the specified SID          
  904. ' *** --------------------------------------------------------------------------------
  905. ' ***
  906. Function GetGroupName(strSID)
  907.     Dim colGroups, oGroup
  908.     Set colGroups = oWMI.ExecQuery("Select * from Win32_Group where SID = '" & strSID & "'")
  909.     For Each oGroup in colGroups
  910.         GetGroupName = oGroup.Name
  911.         Exit For
  912.     Next
  913.     
  914.     Set colGroups = Nothing
  915. End Function
  916. ' ***
  917. ' *** --------------------------------------------------------------------------------
  918. ' *** Name:         Quit
  919. ' *** --------------------------------------------------------------------------------
  920. ' *** Purpose:         Destroy objects and quit the script.
  921. ' *** --------------------------------------------------------------------------------
  922. ' ***
  923. Sub Quit
  924.     Set oGroupUsers  = Nothing
  925.     Set oGroupAdmins = Nothing
  926.     Set oAccounts    = Nothing
  927.     Set oFso         = Nothing
  928.     Set oNetwork     = Nothing
  929.     Set oShell       = Nothing
  930.     Set oWMI         = Nothing
  931.     WScript.Quit
  932. End Sub
  933. ]]>
  934. </script>
  935. </job>
  936. </package>