Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3301 lines
160 KiB

  1. '******************************************************************************
  2. '*
  3. '* Copyright (c) Microsoft Corporation. All rights reserved.
  4. '*
  5. '* Module Name: PAGEFILECONFIG.vbs
  6. '*
  7. '* Abstract: Enables an administrator to display and configure
  8. '* a systems paging file Virtual Memory settings.
  9. '*
  10. '*
  11. '******************************************************************************
  12. OPTION EXPLICIT
  13. ON ERROR RESUME NEXT
  14. Err.Clear
  15. '******************************************************************************
  16. ' Start of Localization Content
  17. '******************************************************************************
  18. ' constants used for format selection
  19. CONST L_PatternFormat_Text = "^(table|list|csv)$"
  20. CONST L_DefaultFormat_Text = "list"
  21. ' Valid volume pattern [ a,b drives are invalid ]
  22. CONST L_VolumePatternFormat_Text = "^([c-zC-Z]:|\*)$"
  23. ' constants for showresults
  24. CONST L_Na_Text = "N/A"
  25. CONST L_MachineName_Text = "System Name"
  26. CONST L_User_Text = "User"
  27. CONST L_Password_Text = "Password"
  28. CONST L_Intsize_Text = "Initial Size"
  29. CONST L_Maxsize_Text = "Maximum Size"
  30. CONST L_Volume_Text = "Volume Name"
  31. CONST L_Format_Text = "Format"
  32. ' the column headers used in the output display
  33. CONST L_ColHeaderHostname_Text = "Host Name"
  34. CONST L_ColHeaderDrive_Text = "Drive/Volume"
  35. CONST L_ColHeaderVolumeLabel_Text = "Volume Label"
  36. CONST L_ColHeaderFileName_Text = "Location\File Name"
  37. CONST L_ColHeaderInitialSize_Text = "Initial Size"
  38. CONST L_ColHeaderMaximumSize_Text = "Maximum Size"
  39. CONST L_ColHeaderCurrentSize_Text = "Current Size"
  40. CONST L_ColHeaderFreeSpace_Text = "Total Free Space"
  41. CONST L_ColHeaderTotalMinimumSize_Text = "Total (All Drives): Minimum Size"
  42. CONST L_ColHeaderTotalRecommendedSize_Text = "Total (All Drives): Recommended Size"
  43. CONST L_ColHeaderTotalSize_Text = "Total (All Drives): Currently Allocated"
  44. ' user reply for the warning messages
  45. CONST L_UserReplyYes_Text = "y"
  46. CONST L_UserReplyNo_Text = "n"
  47. ' constants for CScript usage
  48. CONST L_UseCscript1_ErrorMessage = "This script should be executed from the Command Prompt using CSCRIPT.EXE."
  49. CONST L_UseCscript2_ErrorMessage = "For example: CSCRIPT PAGEFILECONFIG.vbs <arguments>"
  50. CONST L_UseCscript3_ErrorMessage = "To set CScript as the default application to run .vbs files run the following"
  51. CONST L_UseCscript4_ErrorMessage = " CSCRIPT //H:CSCRIPT //S"
  52. CONST L_UseCscript5_ErrorMessage = "You can then run ""PAGEFILECONFIG.vbs <arguments>"" without preceding the script with CSCRIPT."
  53. ' common constants for showing help for all the options
  54. CONST L_UsageDescription_Text = "Description:"
  55. CONST L_UsageParamList_Text = "Parameter List:"
  56. CONST L_UsageExamples_Text = "Examples:"
  57. CONST L_UsageMachineName_Text = " /S system Specifies the remote system to connect to."
  58. CONST L_UsageUserNameLine1_Text = " /U [domain\]user Specifies the user context under which"
  59. CONST L_UsageUserNameLine2_Text = " the command should execute."
  60. CONST L_UsagePasswordLine1_Text = " /P password Specifies the password for the given"
  61. CONST L_UsagePasswordLine2_Text = " user context."
  62. ' constants for showing help
  63. CONST L_ShowUsageLine02_Text = "PAGEFILECONFIG.vbs /parameter [arguments]"
  64. CONST L_ShowUsageLine05_Text = " Enables an administrator to display and configure a system's "
  65. CONST L_ShowUsageLine06_Text = " paging file Virtual Memory settings."
  66. CONST L_ShowUsageLine08_Text = "Parameter List:"
  67. CONST L_ShowUsageLine09_Text = " /Change Changes a system's existing paging file"
  68. CONST L_ShowUsageLine10_Text = " Virtual Memory settings."
  69. CONST L_ShowUsageLine12_Text = " /Create Creates/Adds an additional ""Paging File"" to a system."
  70. CONST L_ShowUsageLine14_Text = " /Delete Deletes a ""Paging File"" from a system."
  71. CONST L_ShowUsageLine16_Text = " /Query Displays a system's paging file"
  72. CONST L_ShowUsageLine17_Text = " Virtual Memory settings."
  73. CONST L_ShowUsageLine19_Text = "Examples:"
  74. CONST L_ShowUsageLine20_Text = " PAGEFILECONFIG.vbs"
  75. CONST L_ShowUsageLine21_Text = " PAGEFILECONFIG.vbs /?"
  76. CONST L_ShowUsageLine22_Text = " PAGEFILECONFIG.vbs /Change /?"
  77. CONST L_ShowUsageLine23_Text = " PAGEFILECONFIG.vbs /Create /?"
  78. CONST L_ShowUsageLine24_Text = " PAGEFILECONFIG.vbs /Delete /?"
  79. CONST L_ShowUsageLine25_Text = " PAGEFILECONFIG.vbs /Query /?"
  80. ' constants for showing help for /Change option
  81. CONST L_ShowChangeUsageLine02_Text = "PAGEFILECONFIG.vbs /Change [/S system [/U username [/P password]]]"
  82. CONST L_ShowChangeUsageLine03_Text = " { [/I initialsize] [/M maximumsize] }"
  83. CONST L_ShowChangeUsageLine04_Text = " /VO volume1 [/VO volume2 [... [/VO volumeN]]]"
  84. CONST L_ShowChangeUsageLine07_Text = " Changes an existing paging file's Virtual Memory Settings."
  85. CONST L_ShowChangeUsageLine18_Text = " /I initialsize Specifies the new initial size (in MB)"
  86. CONST L_ShowChangeUsageLine19_Text = " to use for the page file specified."
  87. CONST L_ShowChangeUsageLine21_Text = " /M maximumsize Specifies the new maximum size (in MB)"
  88. CONST L_ShowChangeUsageLine22_Text = " to use for the page file specified."
  89. CONST L_ShowChangeUsageLine24_Text = " /VO volumeletter Specifies the local drive who's page"
  90. CONST L_ShowChangeUsageLine25_Text = " file settings need to be changed. Specify"
  91. CONST L_ShowChangeUsageLine26_Text = " '*' to select all the local drives."
  92. CONST L_ShowChangeUsageLine27_Text = " Example: ""C:"" or ""*"""
  93. CONST L_ShowChangeUsageLine30_Text = " PAGEFILECONFIG.vbs /Change /?"
  94. CONST L_ShowChangeUsageLine31_Text = " PAGEFILECONFIG.vbs /Change /M 400 /VO c:"
  95. CONST L_ShowChangeUsageLine32_Text = " PAGEFILECONFIG.vbs /Change /S system /U user /M 400 /VO c:"
  96. CONST L_ShowChangeUsageLine33_Text = " PAGEFILECONFIG.vbs /Change /S system /U user /I 20 /VO *"
  97. CONST L_ShowChangeUsageLine34_Text = " PAGEFILECONFIG.vbs /Change /S system /U user /P password /I 200"
  98. CONST L_ShowChangeUsageLine35_Text = " /M 500 /VO c: /VO d:"
  99. ' constants for showing help for /Create option
  100. CONST L_ShowCreateUsageLine02_Text = "PAGEFILECONFIG.vbs /Create [/S system [/U username [/P password]]]"
  101. CONST L_ShowCreateUsageLine03_Text = " /I initialsize /M maximumsize"
  102. CONST L_ShowCreateUsageLine04_Text = " /VO volume1 [/VO volume2 [... [/VO volumeN]]]"
  103. CONST L_ShowCreateUsageLine07_Text = " Creates/Adds an additional ""Paging File"" to a system."
  104. CONST L_ShowCreateUsageLine18_Text = " /I initialsize Specifies the initial size (in MB) to use"
  105. CONST L_ShowCreateUsageLine19_Text = " for the page file being created."
  106. CONST L_ShowCreateUsageLine21_Text = " /M maximumsize Specifies the maximum size (in MB) to use"
  107. CONST L_ShowCreateUsageLine22_Text = " for the page file being created."
  108. CONST L_ShowCreateUsageLine24_Text = " /VO volumeletter Specifies the local drive on which the"
  109. CONST L_ShowCreateUsageLine25_Text = " page file has to be created. Specify '*'"
  110. CONST L_ShowCreateUsageLine26_Text = " to select all the local drives."
  111. CONST L_ShowCreateUsageLine27_Text = " Example: ""C:"" or ""*"""
  112. CONST L_ShowCreateUsageLine30_Text = " PAGEFILECONFIG.vbs /Create /?"
  113. CONST L_ShowCreateUsageLine31_Text = " PAGEFILECONFIG.vbs /Create /I 140 /M 300 /VO d:"
  114. CONST L_ShowCreateUsageLine32_Text = " PAGEFILECONFIG.vbs /Create /S system /U user /I 150 /M 300 /VO d:"
  115. CONST L_ShowCreateUsageLine33_Text = " PAGEFILECONFIG.vbs /Create /S system /U user /I 50 /M 200 /VO *"
  116. CONST L_ShowCreateUsageLine34_Text = " PAGEFILECONFIG.vbs /Create /S system /U user /P password /I 100"
  117. CONST L_ShowCreateUsageLine35_Text = " /M 600 /VO d: /VO e: /VO f:"
  118. ' constants for showing help for /Delete option
  119. CONST L_ShowDeleteUsageLine02_Text = "PAGEFILECONFIG.vbs /Delete [/S system [/U username [/P password]]]"
  120. CONST L_ShowDeleteUsageLine03_Text = " /VO volume1 [/VO volume2 [... [/VO volumeN]]]"
  121. CONST L_ShowDeleteUsageLine06_Text = " Deletes paging file(s) from a system."
  122. CONST L_ShowDeleteUsageLine17_Text = " /VO volumeletter Specifies the local drive who's page"
  123. CONST L_ShowDeleteUsageLine18_Text = " file has to be deleted."
  124. CONST L_ShowDeleteUsageLine19_Text = " Example: ""C:"""
  125. CONST L_ShowDeleteUsageLine22_Text = " PAGEFILECONFIG.vbs /Delete /?"
  126. CONST L_ShowDeleteUsageLine23_Text = " PAGEFILECONFIG.vbs /Delete /VO d:"
  127. CONST L_ShowDeleteUsageLine24_Text = " PAGEFILECONFIG.vbs /Delete /S system /U user /VO d: /VO e:"
  128. CONST L_ShowDeleteUsageLine25_Text = " PAGEFILECONFIG.vbs /Delete /S system /U user /P password /VO d:"
  129. ' constants for showing help for /Query option
  130. CONST L_ShowQueryUsageLine02_Text = "PAGEFILECONFIG.vbs /Query [/S system [/U username [/P password]]]"
  131. CONST L_ShowQueryUsageLine03_Text = " [/FO format]"
  132. CONST L_ShowQueryUsageLine06_Text = " Displays a system's paging file Virtual Memory settings."
  133. CONST L_ShowQueryUsageLine17_Text = " /FO format Specifies the format in which the output"
  134. CONST L_ShowQueryUsageLine18_Text = " is to be displayed."
  135. CONST L_ShowQueryUsageLine19_Text = " Valid values: ""TABLE"", ""LIST"", ""CSV""."
  136. CONST L_ShowQueryUsageLine22_Text = " PAGEFILECONFIG.vbs"
  137. CONST L_ShowQueryUsageLine23_Text = " PAGEFILECONFIG.vbs /Query"
  138. CONST L_ShowQueryUsageLine24_Text = " PAGEFILECONFIG.vbs /Query /?"
  139. CONST L_ShowQueryUsageLine25_Text = " PAGEFILECONFIG.vbs /Query /FO table"
  140. CONST L_ShowQueryUsageLine26_Text = " PAGEFILECONFIG.vbs /Query /S system /U user"
  141. CONST L_ShowQueryUsageLine27_Text = " PAGEFILECONFIG.vbs /Query /S system /U user /P password /FO LIST"
  142. ' constants for error messages
  143. CONST L_UnableToInclude_ErrorMessage = "ERROR: Unable to include the common module ""CmdLib.Wsc""."
  144. CONST L_InvalidHelpUsage_ErrorMessage = "ERROR: Invalid Help Usage. Use only /? for help."
  145. CONST L_InvalidParameter_ErrorMessage = "ERROR: Invalid Argument/Option - '%1'."
  146. CONST L_InvalidInput_ErrorMessage = "ERROR: Invalid Input. Please Check the input values."
  147. CONST L_InvalidCredentials_ErrorMessage = "ERROR: Invalid credentials. Verify the machine, user and password given."
  148. CONST L_InvalidVolumeName_ErrorMessage = "ERROR: Invalid volume '%1' specified."
  149. CONST L_InvalidUserReply_ErrorMessage = "ERROR: Invalid Choice. Enter a valid choice."
  150. CONST L_FailCreateObject_ErrorMessage = "ERROR: Unable to create object."
  151. CONST L_UnableToRetrieveInfo_ErrorMessage = "ERROR: Unable to retrieve information."
  152. CONST L_CannotCreate_ErrorMessage = "ERROR: Page File for the specified volume cannot be created."
  153. CONST L_InvalidPhysicalDrive_ErrorMessage = "ERROR: Volume '%1' is not a valid physical drive."
  154. CONST L_UpdateFailed_ErrorMessage = "ERROR: Pagefile updation failed."
  155. CONST L_InvalidInitSizeValue_ErrorMessage = "ERROR: Enter a numeric value for the initial page file size."
  156. CONST L_InvalidMaxSizeValue_ErrorMessage = "ERROR: Enter a numeric value for the maximum page file size."
  157. ' constant for hint message to show remote connectivity failure
  158. CONST L_HintCheckConnection_Message = "ERROR: Please check the system name, credentials and WBEM Core."
  159. ' constants for info. messages
  160. CONST L_PageFileDoesNotExist_ErrorMessage = "INFO: No pagefile exists on volume '%1'"
  161. CONST L_NoPageFiles_Message = "INFO: No Page File(s) Available."
  162. ' constants for Syntax Error Messages
  163. CONST L_InvalidSyntax_ErrorMessage = "ERROR: Invalid Syntax."
  164. CONST L_InvalidServerName_ErrorMessage = "ERROR: Invalid Syntax. System name cannot be empty."
  165. CONST L_InvalidUserName_ErrorMessage = "ERROR: Invalid Syntax. User name cannot be empty."
  166. CONST L_TypeUsage_Message = "Type ""%1 /?"" for usage."
  167. CONST L_TypeCreateUsage_Message = "Type ""%1 /Create /?"" for usage."
  168. CONST L_TypeChangeUsage_Message = "Type ""%1 /Change /?"" for usage."
  169. CONST L_TypeDeleteUsage_Message = "Type ""%1 /Delete /?"" for usage."
  170. CONST L_TypeQueryUsage_Message = "Type ""%1 /Query /?"" for usage."
  171. ' constants for missing mandatory option messages
  172. CONST L_VolumeNameNotSpecified_ErrorMessage = "Mandatory option '/VO' is missing."
  173. CONST L_InitialSizeNotSpecified_ErrorMessage = "Mandatory option '/I' is missing."
  174. CONST L_MaximumSizeNotSpecified_ErrorMessage = "Mandatory option '/M' is missing."
  175. CONST L_NoneoftheSizeSpecified_ErrorMessage = "Mandatory options '/I', '/M' are missing."
  176. CONST L_FormatNotSpecified_ErrorMessage = "Mandatory options '/FO' is missing."
  177. ' error messages for invalid usage of s,u,p switches
  178. CONST L_InvalidServerCredentials_ErrorMessage = "ERROR: Invalid Syntax. /U can be specified only when /S is specified."
  179. CONST L_InvalidUserCredentials_ErrorMessage = "ERROR: Invalid Syntax. /P can be specified only when /U is specified."
  180. ' constants for Mutliple line Error Messages
  181. CONST L_InsufficientMaxSize1_ErrorMessage = "ERROR: The maximum page file size on volume '%1' should be greater than or "
  182. CONST L_InsufficientMaxSize2_ErrorMessage = " equal to the initial page file size, and less than %2 MB or less "
  183. CONST L_InsufficientMaxSize3_ErrorMessage = " than the disk size."
  184. CONST L_InitialSizeRange1_ErrorMessage = "ERROR: The initial paging file size must be between 2 MB and %1 MB, and "
  185. CONST L_InitialSizeRange2_ErrorMessage = " cannot exceed the amount of free space on the drive you have selected. "
  186. CONST L_NotEnoughSpace1_ErrorMessage = "ERROR: There is not enough space on this drive for the paging file specified."
  187. CONST L_NotEnoughSpace2_ErrorMessage = " Please enter a smaller number or free some disk space."
  188. CONST L_AtLeastFiveMB1_ErrorMessage = "ERROR: There is not enough space on this drive to create the page file size "
  189. CONST L_AtLeastFiveMB2_ErrorMessage = " specified. At least 5 megabytes of free disk space must be left after"
  190. CONST L_AtLeastFiveMB3_ErrorMessage = " the page file is created. Specify a smaller page file size or free some "
  191. CONST L_AtLeastFiveMB4_ErrorMessage = " disk space."
  192. CONST L_DiskTooSmall1_ErrorMessage = "ERROR: Drive '%1' is too small for the maximum paging file size specified."
  193. CONST L_DiskTooSmall2_ErrorMessage = " Please enter a smaller number."
  194. ' constants for Mutliple line Warning Messages
  195. CONST L_GrowsToFreeSpaceWarning1_Message = "WARNING: Drive '%1' does not have enough free space for the maximum paging "
  196. CONST L_GrowsToFreeSpaceWarning2_Message = " file specified. If you continue with this setting, the paging file "
  197. CONST L_GrowsToFreeSpaceWarning3_Message = " will only grow to the size of the available free space (%2 MB)."
  198. CONST L_CrashDumpSettingWarning1_Message = "WARNING: If the pagefile on volume '%1' has an initial size of less than"
  199. CONST L_CrashDumpSettingWarning2_Message = " %2, then the system may not be able to create debugging"
  200. CONST L_CrashDumpSettingWarning3_Message = " information file if a STOP error occurs."
  201. ' constants for Multiple line SUCCESS / SKIPPING messages
  202. CONST L_ChangeIntSuccess1_Message = "SUCCESS: The initial size for the paging file on '%1' was changed from "
  203. CONST L_ChangeIntSuccess2_Message = " %2 MB to %3 MB."
  204. CONST L_ChangeMaxSuccess1_Message = "SUCCESS: The maximum size for the paging file on '%1' was changed from "
  205. CONST L_ChangeMaxSuccess2_Message = " %2 MB to %3 MB."
  206. CONST L_ChangeIntSkipping1_Message = "SKIPPING: The initial size specified for the paging file on '%1' is same as "
  207. CONST L_ChangeIntSkipping2_Message = " the present value."
  208. CONST L_ChangeMaxSkipping1_Message = "SKIPPING: The maximum size specified for the paging file on '%1' is same as "
  209. CONST L_ChangeMaxSkipping2_Message = " the present value."
  210. CONST L_CreateSuccess1_Message = "SUCCESS: A paging file with initial size of %1 MB and a maximum size "
  211. CONST L_CreateSuccess2_Message = " of %2 MB was created on the volume: '%3'"
  212. CONST L_CreateSkipping_Message = "SKIPPING: A paging file already exists on the volume: '%1'"
  213. CONST L_DeleteSuccess_Message = "SUCCESS: The paging file from volume '%1' has successfully been removed."
  214. ' constant for other error messages
  215. CONST L_InvalidFormat_ErrorMessage = "Invalid format '%1' specified."
  216. CONST L_SystemManagedSize_ErrorMessage = "Access Denied: System managed size on volume '%1'"
  217. CONST L_PromptForContinueAnyWay_Message = "Continue Anyway [y/n]?"
  218. CONST L_NotAllowedMoreThanOnce_ErrorMessage = "'%1' option is not allowed more than '1' time(s)."
  219. CONST L_RestartComputer_Message = "Restart the computer for these changes to effect."
  220. '******************************************************************************
  221. ' END of Localization Content
  222. '******************************************************************************
  223. ' the main options
  224. CONST OPTION_HELP = "?"
  225. CONST OPTION_CHANGE = "change"
  226. CONST OPTION_CREATE = "create"
  227. CONST OPTION_DELETE = "delete"
  228. CONST OPTION_QUERY = "query"
  229. ' the suboptions
  230. CONST SUB_OPTION_SERVER = "s"
  231. CONST SUB_OPTION_USER = "u"
  232. CONST SUB_OPTION_PASSWORD = "p"
  233. CONST SUB_OPTION_INTSIZE = "i"
  234. CONST SUB_OPTION_MAXSIZE = "m"
  235. CONST SUB_OPTION_VOLUME = "vo"
  236. CONST SUB_OPTION_FORMAT = "fo"
  237. ' constant for CScript
  238. CONST CONST_CSCRIPT = 2
  239. ' constants for error codes
  240. CONST CONST_ERROR = 0
  241. ' constants for options
  242. CONST CONST_SHOW_USAGE = 3
  243. CONST CONST_CHANGE_OPTION = 11
  244. CONST CONST_CREATE_OPTION = 21
  245. CONST CONST_DELETE_OPTION = 31
  246. CONST CONST_QUERY_OPTION = 41
  247. ' constant for matched pattern
  248. CONST CONST_NO_MATCHES_FOUND = 0
  249. ' utility specific constants
  250. CONST INITIAL_SIZE_LB = 2
  251. CONST DRIVE_TYPE = 3
  252. CONST MEGA_BYTES = " MB"
  253. CONST SIZE_FACTOR = 1.5
  254. CONST CONVERSION_FACTOR = 1048576
  255. CONST PAGEFILE_DOT_SYS = "\pagefile.sys"
  256. ' constant for the UNC format server name
  257. CONST UNC_FORMAT_SERVERNAME_PREFIX = "\\"
  258. ' constants for exit values
  259. CONST EXIT_SUCCESS = 0
  260. CONST EXIT_UNEXPECTED = 255
  261. CONST EXIT_INVALID_INPUT = 254
  262. CONST EXIT_METHOD_FAIL = 250
  263. CONST EXIT_QUERY_FAIL = 253
  264. CONST EXIT_INVALID_PARAM = 999
  265. ' Define namespace and class names of wmi
  266. CONST CONST_WBEM_FLAG = 131072
  267. CONST CONST_NAMESPACE_CIMV2 = "root\cimv2"
  268. CONST CLASS_PAGE_FILE_SETTING = "Win32_PageFileSetting"
  269. CONST CLASS_LOGICAL_DISK = "Win32_LogicalDisk"
  270. CONST CLASS_COMPUTER_SYSTEM = "Win32_ComputerSystem"
  271. CONST CLASS_PAGE_FILE_USAGE = "Win32_PageFileUsage"
  272. CONST CLASS_OPERATING_SYSTEM = "Win32_OperatingSystem"
  273. CONST CLASS_PERFDISK_PHYSICAL_DISK = "Win32_PerfRawData_PerfDisk_PhysicalDisk"
  274. ' constants for data lengths for ShowResults (15,13,13,19,20,20,20,22)
  275. CONST CONST_HOSTNAME_LENGTH = 15
  276. CONST CONST_DRIVENAME_LENGTH = 13
  277. CONST CONST_VOLLABEL_LENGTH = 13
  278. CONST CONST_PAGEFILENAME_LENGTH = 19
  279. CONST CONST_INTSIZE_LENGTH = 20
  280. CONST CONST_MAXSIZE_LENGTH = 20
  281. CONST CONST_CURRENTSIZE_LENGTH = 20
  282. CONST CONST_FREESPACE_LENGTH = 22
  283. ' constants for data lengths for ShowResults (15,33,37,40)
  284. CONST CONST_TOTALMINSIZE_LENGTH = 33
  285. CONST CONST_TOTALRECSIZE_LENGTH = 37
  286. CONST CONST_TOTALSIZE_LENGTH = 40
  287. Dim UseCscriptErrorMessage ' string to store the CScript usage
  288. Dim blnLocalConnection ' flag for local connection
  289. Dim component ' object for the common module
  290. ' Error Messages
  291. Dim InsufficientMaxSizeErrorMessage
  292. Dim InitialSizeRangeErrorMessage
  293. Dim NotEnoughSpaceErrorMessage
  294. Dim AtLeastFiveMBErrorMessage
  295. Dim DiskTooSmallErrorMessage
  296. ' Warning Messages
  297. Dim GrowsToFreeSpaceWarningMessage
  298. Dim CrashDumpSettingWarningMessage
  299. ' Success / Skipping messages
  300. Dim ChangeIntSuccessMessage
  301. Dim ChangeMaxSuccessMessage
  302. Dim ChangeIntSkippingMessage
  303. Dim ChangeMaxSkippingMessage
  304. Dim CreateSuccessMessage
  305. UseCscriptErrorMessage = L_UseCscript1_ErrorMessage & vbCRLF & _
  306. L_UseCscript2_ErrorMessage & vbCRLF & vbCRLF & _
  307. L_UseCscript3_ErrorMessage & vbCRLF & _
  308. L_UseCscript4_ErrorMessage & vbCRLF & vbCRLF & _
  309. L_UseCscript5_ErrorMessage
  310. InsufficientMaxSizeErrorMessage = L_InsufficientMaxSize1_ErrorMessage & vbCRLF & _
  311. L_InsufficientMaxSize2_ErrorMessage & vbCRLF & _
  312. L_InsufficientMaxSize3_ErrorMessage
  313. InitialSizeRangeErrorMessage = L_InitialSizeRange1_ErrorMessage & vbCRLF & _
  314. L_InitialSizeRange2_ErrorMessage
  315. NotEnoughSpaceErrorMessage = L_NotEnoughSpace1_ErrorMessage & vbCRLF & _
  316. L_NotEnoughSpace2_ErrorMessage
  317. AtLeastFiveMBErrorMessage = L_AtLeastFiveMB1_ErrorMessage & vbCRLF & _
  318. L_AtLeastFiveMB2_ErrorMessage & vbCRLF & _
  319. L_AtLeastFiveMB3_ErrorMessage & vbCRLF & _
  320. L_AtLeastFiveMB4_ErrorMessage
  321. DiskTooSmallErrorMessage = L_DiskTooSmall1_ErrorMessage & vbCRLF & _
  322. L_DiskTooSmall2_ErrorMessage
  323. GrowsToFreeSpaceWarningMessage = L_GrowsToFreeSpaceWarning1_Message & vbCRLF & _
  324. L_GrowsToFreeSpaceWarning2_Message & vbCRLF & _
  325. L_GrowsToFreeSpaceWarning3_Message
  326. CrashDumpSettingWarningMessage = L_CrashDumpSettingWarning1_Message & vbCRLF & _
  327. L_CrashDumpSettingWarning2_Message & vbCRLF & _
  328. L_CrashDumpSettingWarning3_Message
  329. ChangeIntSuccessMessage = L_ChangeIntSuccess1_Message & vbCRLF & _
  330. L_ChangeIntSuccess2_Message
  331. ChangeMaxSuccessMessage = L_ChangeMaxSuccess1_Message & vbCRLF & _
  332. L_ChangeMaxSuccess2_Message
  333. ChangeIntSkippingMessage = L_ChangeIntSkipping1_Message & vbCRLF & _
  334. L_ChangeIntSkipping2_Message
  335. ChangeMaxSkippingMessage = L_ChangeMaxSkipping1_Message & vbCRLF & _
  336. L_ChangeMaxSkipping2_Message
  337. CreateSuccessMessage = L_CreateSuccess1_Message & vbCRLF & _
  338. L_CreateSuccess2_Message
  339. blnLocalConnection = FALSE
  340. ' create the object for commom module
  341. Set component = CreateObject( "Microsoft.CmdLib" )
  342. ' check if the commom module(CmdLib.wsc) is not registered
  343. If Err.Number Then
  344. Err.Clear
  345. WScript.Echo(L_UnableToInclude_ErrorMessage)
  346. WScript.Quit(EXIT_METHOD_FAIL)
  347. End If
  348. ' set the scripting host to WScript
  349. Set component.ScriptingHost = WScript.Application
  350. ' Check whether the script is run using CScript
  351. If CInt(component.checkScript) <> CONST_CSCRIPT Then
  352. WScript.Echo (UseCscriptErrorMessage)
  353. WScript.Quit(EXIT_UNEXPECTED)
  354. End If
  355. ' call the main function
  356. Call VBMain()
  357. ' quit with exit value = 0
  358. WScript.Quit(EXIT_SUCCESS)
  359. '******************************************************************************
  360. '* Sub: VBMain
  361. '*
  362. '* Purpose: This is main function to starts execution
  363. '*
  364. '* Input: None
  365. '*
  366. '* Output: None
  367. '*
  368. '******************************************************************************
  369. Sub VBMain()
  370. ON ERROR RESUME NEXT
  371. Err.Clear
  372. ' Declaring main variables
  373. Dim strMachine ' machine to configure page files on
  374. Dim strUserName ' user name to connect to the machine
  375. Dim strPassword ' password for the user
  376. Dim intIntSize ' initial size for the page file
  377. Dim intMaxSize ' maximum size for the page file
  378. Dim strVolName ' volume name
  379. Dim objVols ' object containing volume names
  380. Dim strFormat ' query display format
  381. Dim intMainOption ' main option specified
  382. Dim intTempResult ' temporary variable to hold the return value
  383. Dim blnValidArguments ' stores the return value of ValidateArguments
  384. ' Initializing Variables
  385. intTempResult = CONST_ERROR ' default is CONST_ERROR (=0)
  386. strFormat = L_DefaultFormat_Text ' default format is LIST
  387. Set objVols = CreateObject("Scripting.Dictionary")
  388. objVols.CompareMode = VBBinaryCompare
  389. If Err.Number Then
  390. ' Unable to create the dictionary object.
  391. Err.Clear
  392. WScript.Echo(L_FailCreateObject_ErrorMessage)
  393. WScript.Quit(EXIT_METHOD_FAIL)
  394. End If
  395. intTempResult = intParseCmdLine( strMachine, _
  396. strUserName, _
  397. strPassword, _
  398. intIntSize, _
  399. intMaxSize, _
  400. strVolName, _
  401. objVols, _
  402. strFormat, _
  403. intMainOption )
  404. ' Select the operation specified by the user
  405. Select Case intTempResult
  406. Case CONST_SHOW_USAGE
  407. Select Case intMainOption
  408. Case CONST_CHANGE_OPTION
  409. Call ShowChangeUsage()
  410. Case CONST_CREATE_OPTION
  411. Call ShowCreateUsage()
  412. Case CONST_DELETE_OPTION
  413. Call ShowDeleteUsage()
  414. Case CONST_QUERY_OPTION
  415. Call ShowQueryUsage()
  416. Case Else
  417. Call ShowUsage()
  418. End Select
  419. Case CONST_CHANGE_OPTION
  420. blnValidArguments = ValidateArguments (strMachine, strUserName, strPassword, _
  421. intIntSize, intMaxSize, objVols, strFormat, _
  422. intMainOption)
  423. ' If all arguments valid, proceed
  424. If blnValidArguments Then
  425. Call ProcessChange(strMachine, strUserName, strPassword, _
  426. intIntSize, intMaxSize, objVols)
  427. End If
  428. Case CONST_CREATE_OPTION
  429. blnValidArguments = ValidateArguments (strMachine, strUserName, strPassword, _
  430. intIntSize, intMaxSize, objVols, strFormat, _
  431. intMainOption)
  432. ' If all arguments valid, proceed
  433. If blnValidArguments Then
  434. Call ProcessCreate(strMachine, strUserName, strPassword, _
  435. intIntSize, intMaxSize, objVols)
  436. End If
  437. Case CONST_DELETE_OPTION
  438. blnValidArguments = ValidateArguments (strMachine, strUserName, strPassword, _
  439. intIntSize, intMaxSize, objVols, strFormat, _
  440. intMainOption)
  441. ' If all arguments valid, proceed
  442. If blnValidArguments Then
  443. Call ProcessDelete(strMachine, strUserName, strPassword, objVols)
  444. ' Here wild cards cannot be specified
  445. End If
  446. Case CONST_QUERY_OPTION
  447. blnValidArguments = ValidateArguments (strMachine, strUserName, strPassword, _
  448. intIntSize, intMaxSize, objVols, strFormat, _
  449. intMainOption)
  450. ' If all arguments valid, proceed
  451. If blnValidArguments Then
  452. Call ProcessQuery(strMachine, strUserName, strPassword, strFormat)
  453. End If
  454. Case CONST_ERROR
  455. WSCript.Quit(EXIT_INVALID_INPUT)
  456. End Select
  457. End Sub
  458. '******************************************************************************
  459. '* Function: intParseCmdLine
  460. '*
  461. '* Purpose: Parses the command line arguments to the variables
  462. '*
  463. '* Input:
  464. '* [out] strMachine machine to configure page files on
  465. '* [out] strUserName user name to connect to the machine
  466. '* [out] strPassword password for the user
  467. '* [out] intIntSize initial size for the page file
  468. '* [out] intMaxSize maximum size for the page file
  469. '* [in] strVolName individual volume name(s)
  470. '* [out] objVols object containing volume names
  471. '* [out] strFormat query display format
  472. '* [out] intMainOption main option specified
  473. '*
  474. '* Output: Returns CONST_SHOW_USAGE, CONST_CHANGE_OPTION ,
  475. '* CONST_CREATE_OPTION, CONST_DELETE_OPTION ,
  476. '* CONST_QUERY_OPTION or CONST_ERROR.
  477. '* Displays error message and quits if invalid option is asked
  478. '*
  479. '******************************************************************************
  480. Private Function intParseCmdLine( ByRef strMachine, _
  481. ByRef strUserName, _
  482. ByRef strPassword, _
  483. ByRef intIntSize, _
  484. ByRef intMaxSize, _
  485. ByVal strVolName, _
  486. ByRef objVols, _
  487. ByRef strFormat, _
  488. ByRef intMainOption )
  489. ON ERROR RESUME NEXT
  490. Err.Clear
  491. Dim strUserGivenArg ' to temporarily store the user given arguments
  492. Dim intArgIter ' to count the number of arguments given
  493. Dim intQCount ' to count the number of help options given
  494. Dim intMainOptionNumber ' to count the number of main operations selected (Max allowed = 1)
  495. Dim intVolumes ' to store the number of volumes specified
  496. ' Following variables are used to check if a switch if given more than once
  497. Dim blnIntSizeSpecified
  498. Dim blnMaxSizeSpecified
  499. Dim blnFormatSpecified
  500. Dim blnMachineSpecified
  501. Dim blnUserSpecified
  502. Dim blnPasswordSpecified
  503. ' Initialization
  504. strUserGivenArg = ""
  505. intMainOptionNumber = 0
  506. intQCount = 0
  507. intArgIter = 0
  508. intParseCmdLine = 0
  509. ' initially none of the parameters are specified, so set all flags to FALSE
  510. blnIntSizeSpecified = FALSE
  511. blnMaxSizeSpecified = FALSE
  512. blnFormatSpecified = FALSE
  513. blnMachineSpecified = FALSE
  514. blnUserSpecified = FALSE
  515. blnPasswordSpecified = FALSE
  516. ' if no arguments are specified, default option is query
  517. If WScript.Arguments.Count = 0 Then
  518. intParseCmdLine = CONST_QUERY_OPTION
  519. intMainOption = CONST_QUERY_OPTION
  520. End If
  521. ' Retrieve the command line parameters and their values
  522. Do While intArgIter <= WScript.Arguments.Count - 1
  523. strUserGivenArg = WScript.Arguments.Item(intArgIter)
  524. ' check if the first character is a '-' OR '/' symbol
  525. If Left(strUserGivenArg,1) = "/" OR Left(strUserGivenArg,1) = "-" Then
  526. ' ignore the symbol and take the rest as the switch specified
  527. strUserGivenArg = Right(strUserGivenArg,Len(strUserGivenArg) - 1)
  528. Select Case LCase(strUserGivenArg)
  529. Case LCase(OPTION_HELP)
  530. intQCount = intQCount + 1
  531. If (CInt(intQCount) >= 2 OR CInt(WScript.Arguments.Count) > 2) Then
  532. intParseCmdLine = CONST_ERROR
  533. WScript.Echo(L_InvalidHelpUsage_ErrorMessage)
  534. Exit Function
  535. Else
  536. intParseCmdLine = CONST_SHOW_USAGE
  537. intArgIter = intArgIter + 1
  538. End If
  539. Case LCase(OPTION_CHANGE)
  540. If intQCount = 1 Then ' intQCount = 1 means help specified
  541. intParseCmdLine = CONST_SHOW_USAGE
  542. Else
  543. intParseCmdLine = CONST_CHANGE_OPTION
  544. End If
  545. intMainOption = CONST_CHANGE_OPTION
  546. intMainOptionNumber = intMainOptionNumber + 1
  547. intArgIter = intArgIter + 1
  548. Case LCase(OPTION_CREATE)
  549. If intQCount = 1 Then ' intQCount = 1 means help specified
  550. intParseCmdLine = CONST_SHOW_USAGE
  551. Else
  552. intParseCmdLine = CONST_CREATE_OPTION
  553. End If
  554. intMainOption = CONST_CREATE_OPTION
  555. intMainOptionNumber = intMainOptionNumber + 1
  556. intArgIter = intArgIter + 1
  557. Case LCase(OPTION_DELETE)
  558. If intQCount = 1 Then ' intQCount = 1 means help specified
  559. intParseCmdLine = CONST_SHOW_USAGE
  560. Else
  561. intParseCmdLine = CONST_DELETE_OPTION
  562. End If
  563. intMainOption = CONST_DELETE_OPTION
  564. intMainOptionNumber = intMainOptionNumber + 1
  565. intArgIter = intArgIter + 1
  566. Case LCase(OPTION_QUERY)
  567. If intQCount = 1 Then ' intQCount = 1 means help specified
  568. intParseCmdLine = CONST_SHOW_USAGE
  569. Else
  570. intParseCmdLine = CONST_QUERY_OPTION
  571. End If
  572. intMainOption = CONST_QUERY_OPTION
  573. intMainOptionNumber = intMainOptionNumber + 1
  574. intArgIter = intArgIter + 1
  575. Case LCase(SUB_OPTION_SERVER)
  576. ' Check if server name is given with help usage
  577. If intParseCmdLine = CONST_SHOW_USAGE Then
  578. WScript.Echo(L_InvalidHelpUsage_ErrorMessage)
  579. WScript.Quit(EXIT_INVALID_INPUT)
  580. End If
  581. ' Check if Machine Name is already specified
  582. If NOT blnMachineSpecified Then
  583. blnMachineSpecified = TRUE ' Set Specified Flag to TRUE
  584. If NOT component.getArguments(L_MachineName_Text,strMachine,intArgIter,FALSE) Then
  585. component.VBPrintf L_InvalidSyntax_ErrorMessage
  586. Call typeMessage(intMainOption)
  587. intParseCmdLine = CONST_ERROR
  588. Exit Function
  589. End If
  590. intArgIter = intArgIter + 1
  591. Else
  592. component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _
  593. L_NotAllowedMoreThanOnce_ErrorMessage , _
  594. Array(WScript.Arguments.Item(intArgIter))
  595. ' print the appropriate help usage message
  596. Call typeMessage(intMainOption)
  597. WScript.Quit(EXIT_INVALID_INPUT)
  598. End If
  599. Case LCase(SUB_OPTION_USER)
  600. ' Check if user name is given with help usage
  601. If intParseCmdLine = CONST_SHOW_USAGE Then
  602. WScript.Echo(L_InvalidHelpUsage_ErrorMessage)
  603. WScript.Quit(EXIT_INVALID_INPUT)
  604. End If
  605. ' Check if User Name is already specified
  606. If NOT blnUserSpecified Then
  607. blnUserSpecified = TRUE ' Set Specified Flag to TRUE
  608. If NOT component.getArguments(L_User_Text,strUserName,intArgIter,FALSE) Then
  609. component.VBPrintf L_InvalidSyntax_ErrorMessage
  610. Call typeMessage(intMainOption)
  611. intParseCmdLine = CONST_ERROR
  612. Exit Function
  613. End If
  614. intArgIter = intArgIter + 1
  615. Else
  616. component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _
  617. L_NotAllowedMoreThanOnce_ErrorMessage , _
  618. Array(WScript.Arguments.Item(intArgIter))
  619. ' print the appropriate help usage message
  620. Call typeMessage(intMainOption)
  621. WScript.Quit(EXIT_INVALID_INPUT)
  622. End If
  623. Case LCase(SUB_OPTION_PASSWORD)
  624. ' Check if password is given with help usage
  625. If intParseCmdLine = CONST_SHOW_USAGE Then
  626. WScript.Echo(L_InvalidHelpUsage_ErrorMessage)
  627. WScript.Quit(EXIT_INVALID_INPUT)
  628. End If
  629. ' Check if Password is already specified
  630. If NOT blnPasswordSpecified Then
  631. blnPasswordSpecified = TRUE ' Set Specified Flag to TRUE
  632. If NOT component.getArguments(L_Password_Text,strPassword,intArgIter,FALSE) Then
  633. component.VBPrintf L_InvalidSyntax_ErrorMessage
  634. Call typeMessage(intMainOption)
  635. intParseCmdLine = CONST_ERROR
  636. Exit Function
  637. End If
  638. intArgIter = intArgIter + 1
  639. Else
  640. component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _
  641. L_NotAllowedMoreThanOnce_ErrorMessage , _
  642. Array(WScript.Arguments.Item(intArgIter))
  643. ' print the appropriate help usage message
  644. Call typeMessage(intMainOption)
  645. WScript.Quit(EXIT_INVALID_INPUT)
  646. End If
  647. Case LCase(SUB_OPTION_INTSIZE)
  648. ' Check if initsize is given with help usage
  649. If intParseCmdLine = CONST_SHOW_USAGE Then
  650. WScript.Echo(L_InvalidHelpUsage_ErrorMessage)
  651. WScript.Quit(EXIT_INVALID_INPUT)
  652. End If
  653. ' Check if initsize is already specified
  654. If NOT blnIntSizeSpecified Then
  655. blnIntSizeSpecified = TRUE ' Set Specified Flag to TRUE
  656. If NOT component.getArguments(L_Intsize_Text,intIntSize,intArgIter,FALSE) Then
  657. component.VBPrintf L_InvalidSyntax_ErrorMessage
  658. Call typeMessage(intMainOption)
  659. intParseCmdLine = CONST_ERROR
  660. Exit Function
  661. End If
  662. intArgIter = intArgIter + 1
  663. Else
  664. component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _
  665. L_NotAllowedMoreThanOnce_ErrorMessage , _
  666. Array(WScript.Arguments.Item(intArgIter))
  667. ' print the appropriate help usage message
  668. Call typeMessage(intMainOption)
  669. WScript.Quit(EXIT_INVALID_INPUT)
  670. End If
  671. Case LCase(SUB_OPTION_MAXSIZE)
  672. ' Check if maxsize is given with help usage
  673. If intParseCmdLine = CONST_SHOW_USAGE Then
  674. WScript.Echo(L_InvalidHelpUsage_ErrorMessage)
  675. WScript.Quit(EXIT_INVALID_INPUT)
  676. End If
  677. ' Check if Maxsize is already specified
  678. If NOT blnMaxSizeSpecified Then
  679. blnMaxSizeSpecified = TRUE ' Set Specified Flag to TRUE
  680. If NOT component.getArguments(L_Maxsize_Text,intMaxSize,intArgIter,FALSE) Then
  681. component.VBPrintf L_InvalidSyntax_ErrorMessage
  682. Call typeMessage(intMainOption)
  683. intParseCmdLine = CONST_ERROR
  684. Exit Function
  685. End If
  686. intArgIter = intArgIter + 1
  687. Else
  688. component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _
  689. L_NotAllowedMoreThanOnce_ErrorMessage , _
  690. Array(WScript.Arguments.Item(intArgIter))
  691. ' print the appropriate help usage message
  692. Call typeMessage(intMainOption)
  693. WScript.Quit(EXIT_INVALID_INPUT)
  694. End If
  695. Case LCase(SUB_OPTION_FORMAT)
  696. ' Check if maxsize is given with help usage
  697. If intParseCmdLine = CONST_SHOW_USAGE Then
  698. WScript.Echo(L_InvalidHelpUsage_ErrorMessage)
  699. WScript.Quit(EXIT_INVALID_INPUT)
  700. End If
  701. ' Check if format is already specified
  702. If NOT blnFormatSpecified Then
  703. blnFormatSpecified = TRUE ' Set Specified Flag to TRUE
  704. If NOT component.getArguments(L_Format_Text,strFormat,intArgIter,FALSE) Then
  705. component.VBPrintf L_InvalidSyntax_ErrorMessage
  706. Call typeMessage(intMainOption)
  707. intParseCmdLine = CONST_ERROR
  708. Exit Function
  709. End If
  710. intArgIter = intArgIter + 1
  711. Else
  712. component.VBPrintf L_InvalidSyntax_ErrorMessage & " " & _
  713. L_NotAllowedMoreThanOnce_ErrorMessage , _
  714. Array(WScript.Arguments.Item(intArgIter))
  715. ' print the appropriate help usage message
  716. Call typeMessage(intMainOption)
  717. WScript.Quit(EXIT_INVALID_INPUT)
  718. End If
  719. Case LCase(SUB_OPTION_VOLUME)
  720. ' Check if volume is given with help usage
  721. If intParseCmdLine = CONST_SHOW_USAGE Then
  722. WScript.Echo(L_InvalidHelpUsage_ErrorMessage)
  723. WScript.Quit(EXIT_INVALID_INPUT)
  724. End If
  725. If NOT component.getArguments(L_Volume_Text,strVolName,intArgIter,FALSE) Then
  726. component.VBPrintf L_InvalidSyntax_ErrorMessage
  727. Call typeMessage(intMainOption)
  728. intParseCmdLine = CONST_ERROR
  729. Exit Function
  730. Else
  731. If strVolName = "*" Then
  732. objVols.Add LCase(strVolName), -1
  733. Else
  734. If NOT objVols.Exists(LCase(strVolName)) Then
  735. objVols.Add LCase(strVolName), -1
  736. End If
  737. intVolumes = objVols.Count
  738. End If
  739. End If
  740. intArgIter = intArgIter + 1
  741. Case Else
  742. ' display the invalid param err msg first
  743. component.VBPrintf L_InvalidParameter_ErrorMessage, _
  744. Array(WScript.arguments.Item(intArgIter))
  745. ' then display the 'type ..usage' message
  746. Select Case CInt(intMainOption)
  747. Case CONST_CHANGE_OPTION
  748. component.VBPrintf L_TypeChangeUsage_Message, _
  749. Array(UCase(WScript.ScriptName))
  750. WScript.Quit(EXIT_INVALID_PARAM)
  751. Case CONST_CREATE_OPTION
  752. component.VBPrintf L_TypeCreateUsage_Message, _
  753. Array(UCase(WScript.ScriptName))
  754. WScript.Quit(EXIT_INVALID_PARAM)
  755. Case CONST_DELETE_OPTION
  756. component.VBPrintf L_TypeDeleteUsage_Message, _
  757. Array(UCase(WScript.ScriptName))
  758. WScript.Quit(EXIT_INVALID_PARAM)
  759. Case CONST_QUERY_OPTION
  760. component.VBPrintf L_TypeQueryUsage_Message, _
  761. Array(UCase(WScript.ScriptName))
  762. WScript.Quit(EXIT_INVALID_PARAM)
  763. Case Else
  764. component.VBPrintf L_TypeUsage_Message, _
  765. Array(UCase(WScript.ScriptName))
  766. WScript.Quit(EXIT_INVALID_PARAM)
  767. End Select
  768. End Select
  769. Else
  770. ' invalid argument specified
  771. ' display the invalid param err msg first
  772. component.VBPrintf L_InvalidParameter_ErrorMessage, _
  773. Array(WScript.arguments.Item(intArgIter))
  774. ' then display the 'type ..usage' message
  775. Select Case CInt(intMainOption)
  776. Case CONST_CHANGE_OPTION
  777. component.VBPrintf L_TypeChangeUsage_Message, _
  778. Array(UCase(WScript.ScriptName))
  779. WScript.Quit(EXIT_INVALID_PARAM)
  780. Case CONST_CREATE_OPTION
  781. component.VBPrintf L_TypeCreateUsage_Message, _
  782. Array(UCase(WScript.ScriptName))
  783. WScript.Quit(EXIT_INVALID_PARAM)
  784. Case CONST_DELETE_OPTION
  785. component.VBPrintf L_TypeDeleteUsage_Message, _
  786. Array(UCase(WScript.ScriptName))
  787. WScript.Quit(EXIT_INVALID_PARAM)
  788. Case CONST_QUERY_OPTION
  789. component.VBPrintf L_TypeQueryUsage_Message, _
  790. Array(UCase(WScript.ScriptName))
  791. WScript.Quit(EXIT_INVALID_PARAM)
  792. Case Else
  793. component.VBPrintf L_TypeUsage_Message, _
  794. Array(UCase(WScript.ScriptName))
  795. WScript.Quit(EXIT_INVALID_PARAM)
  796. End Select
  797. End If
  798. Loop
  799. ' check if the there is any volume(s) specified.
  800. If objVols.Count = 0 Then
  801. intVolumes = objVols.Count
  802. End If
  803. ' Check if volumes | * is specified along with help
  804. If (intVolumes > 0 AND intQCount = 1) Then
  805. WScript.Echo(L_InvalidHelpUsage_ErrorMessage)
  806. WScript.Quit(EXIT_INVALID_INPUT)
  807. End If
  808. ' Check if two major operations are selected at a time
  809. If ( intMainOptionNumber > 1 ) Then
  810. WScript.Echo(L_InvalidSyntax_ErrorMessage)
  811. component.VBPrintf L_TypeUsage_Message,Array(UCase(WScript.ScriptName))
  812. WScript.Quit(EXIT_INVALID_INPUT)
  813. ElseIf (intQcount = 0 AND intmainoption = 0) Then
  814. intMainOption = CONST_QUERY_OPTION
  815. End If
  816. ' check if NO major option(s) is specified, but other switches are specified
  817. If ( intMainOptionNumber = 0 ) Then
  818. If blnIntSizeSpecified OR _
  819. blnMaxSizeSpecified OR _
  820. blnFormatSpecified OR _
  821. blnMachineSpecified OR _
  822. blnUserSpecified OR _
  823. blnPasswordSpecified OR _
  824. intVolumes > 0 Then
  825. WScript.Echo(L_InvalidSyntax_ErrorMessage)
  826. component.VBPrintf L_TypeUsage_Message, _
  827. Array(UCase(WScript.ScriptName))
  828. WScript.Quit(EXIT_INVALID_INPUT)
  829. End If
  830. End If
  831. ' check if format is specified with create option
  832. If (intMainOption = CONST_CREATE_OPTION) Then
  833. If blnFormatSpecified Then
  834. WScript.Echo(L_InvalidSyntax_ErrorMessage)
  835. component.VBPrintf L_TypeCreateUsage_Message, _
  836. Array(UCase(WScript.ScriptName))
  837. WScript.Quit(EXIT_INVALID_INPUT)
  838. End If
  839. End If
  840. ' check if format is specified with change option
  841. If (intMainOption = CONST_CHANGE_OPTION) Then
  842. If blnFormatSpecified Then
  843. WScript.Echo(L_InvalidSyntax_ErrorMessage)
  844. component.VBPrintf L_TypeChangeUsage_Message, _
  845. Array(UCase(WScript.ScriptName))
  846. WScript.Quit(EXIT_INVALID_INPUT)
  847. End If
  848. End If
  849. ' check if /Initsize, /Maxsize, /FO are specified
  850. If (intMainOption = CONST_DELETE_OPTION) Then
  851. If (blnIntSizeSpecified OR blnMaxSizeSpecified OR blnFormatSpecified) Then
  852. WScript.Echo(L_InvalidSyntax_ErrorMessage)
  853. component.VBPrintf L_TypeDeleteUsage_Message, _
  854. Array(UCase(WScript.ScriptName))
  855. WScript.Quit(EXIT_INVALID_INPUT)
  856. End If
  857. End If
  858. ' check if /Initsize, /Maxsize, are specified
  859. If (intMainOption = CONST_QUERY_OPTION) Then
  860. If (blnIntSizeSpecified OR blnMaxSizeSpecified) Then
  861. WScript.Echo(L_InvalidSyntax_ErrorMessage)
  862. component.VBPrintf L_TypeQueryUsage_Message, _
  863. Array(UCase(WScript.ScriptName))
  864. WScript.Quit(EXIT_INVALID_INPUT)
  865. End If
  866. End If
  867. End Function
  868. '******************************************************************************
  869. '* Function: ValidateArguments
  870. '*
  871. '* Purpose: Validates the command line arguments given by the user
  872. '*
  873. '* Input:
  874. '* [out] strMachine machine to configure page files on
  875. '* [out] strUserName user name to connect to the machine
  876. '* [out] strPassword password for the user
  877. '* [out] intIntSize the initial size for the page file
  878. '* [out] intMaxSize the maximum size for the page file
  879. '* [out] objVols the object containing volume names
  880. '* [out] strFormat the query display format
  881. '* [out] intMainOption the main option specified
  882. '*
  883. '* Output: Returns true if all valid else displays error message and quits
  884. '* Gets the password from the user if not specified along with User.
  885. '*
  886. '******************************************************************************
  887. Private Function ValidateArguments ( ByRef strMachine, _
  888. ByRef strUserName, _
  889. ByRef strPassword, _
  890. ByRef intIntSize, _
  891. ByRef intMaxSize, _
  892. ByRef objVols, _
  893. ByRef strFormat, _
  894. ByRef intMainOption)
  895. ON ERROR RESUME NEXT
  896. Err.Clear
  897. Dim strMatchPattern ' the pattern to be matched
  898. Dim intVolumes ' to count the no.of volumes specified
  899. Dim arrVolume ' array to store the volumes specified
  900. Dim i ' Loop variable
  901. ' Initialization
  902. intVolumes = CInt(objVols.Count)
  903. arrVolume = objVols.Keys
  904. ValidateArguments = TRUE
  905. i = 0
  906. ' Check if invalid server name is given
  907. If NOT IsEmpty(strMachine) Then
  908. If Trim(strMachine) = vbNullString Then
  909. WScript.Echo(L_InvalidServerName_ErrorMessage)
  910. WScript.Quit(EXIT_INVALID_INPUT)
  911. End If
  912. End If
  913. ' Check if invalid user name is given
  914. If NOT IsEmpty(strUserName) Then
  915. If Trim(strUserName) = vbNullString Then
  916. WScript.Echo(L_InvalidUserName_ErrorMessage)
  917. WScript.Quit(EXIT_INVALID_INPUT)
  918. End If
  919. End If
  920. ' check if user is given without machine OR password
  921. If ((strUserName <> VBEmpty) AND (strMachine = VBEmpty)) Then
  922. WScript.Echo L_InvalidServerCredentials_ErrorMessage
  923. component.VBPrintf L_TypeUsage_Message, _
  924. Array(UCase(WScript.ScriptName))
  925. WScript.Quit(EXIT_INVALID_INPUT)
  926. ' check if password is given without user OR machine
  927. ElseIf ((strPassword <> VBEmpty) AND (strUserName = VBEmpty))Then
  928. WScript.Echo L_InvalidUserCredentials_ErrorMessage
  929. component.VBPrintf L_TypeUsage_Message, _
  930. Array(UCase(WScript.ScriptName))
  931. WScript.Quit(EXIT_INVALID_INPUT)
  932. End If
  933. ' Check if initial size is specified, validate if it is a poistive number
  934. If Len(CStr(intIntSize)) > 0 Then
  935. ' Initsize should be numeric only
  936. ' chr(46) indicates "." (dot)
  937. If NOT (IsNumeric(intIntSize) AND InStr(intIntSize,chr(46)) = 0 AND Instr(intIntSize,"-") = 0) Then
  938. ValidateArguments = FALSE
  939. WScript.Echo L_InvalidInitSizeValue_ErrorMessage
  940. WScript.Quit(EXIT_INVALID_INPUT)
  941. End If
  942. End If
  943. ' Check if maximum size is specified, validate if it is a poistive number
  944. If Len(CStr(intMaxSize)) > 0 Then
  945. ' Maxsize should be numeric only
  946. ' chr(46) indicates "." (dot)
  947. If NOT (IsNumeric(intMaxSize) AND InStr(intMaxSize,chr(46)) = 0 AND Instr(intMaxSize,"-") = 0) Then
  948. ValidateArguments = FALSE
  949. WScript.Echo L_InvalidMaxSizeValue_ErrorMessage
  950. WScript.Quit(EXIT_INVALID_INPUT)
  951. End If
  952. End If
  953. Select Case CInt(intMainOption)
  954. Case CONST_CHANGE_OPTION
  955. ' Valid Cases : either (initsize + volume) OR (maxsize + volume)
  956. ' OR (initsize + maxsize + volume)
  957. ' If none of the parameters (initsize or maxsize) is specified
  958. If (Len(CStr(intIntSize)) = 0 AND Len(CStr(intMaxSize)) = 0) Then
  959. ValidateArguments = FALSE
  960. WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _
  961. L_NoneoftheSizeSpecified_ErrorMessage)
  962. component.VBPrintf L_TypeChangeUsage_Message, _
  963. Array(UCase(WScript.ScriptName))
  964. WScript.Quit(EXIT_INVALID_INPUT)
  965. End If
  966. ' check if the volume is specified
  967. If (objVols.Count = 0) Then
  968. ValidateArguments = FALSE
  969. WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _
  970. L_VolumeNameNotSpecified_ErrorMessage)
  971. component.VBPrintf L_TypeChangeUsage_Message, _
  972. Array(UCase(WScript.ScriptName))
  973. WScript.Quit(EXIT_INVALID_INPUT)
  974. ' check if volume name is valid
  975. ElseIf isValidDrive(objVols,intMainOption) Then
  976. ValidateArguments = TRUE
  977. End If
  978. Case CONST_CREATE_OPTION
  979. ' initsize is required
  980. If ( Len(CStr(intIntSize)) = 0 ) Then
  981. ValidateArguments = FALSE
  982. WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _
  983. L_InitialSizeNotSpecified_ErrorMessage)
  984. component.VBPrintf L_TypeCreateUsage_Message, _
  985. Array(UCase(WScript.ScriptName))
  986. WScript.Quit(EXIT_INVALID_INPUT)
  987. End If
  988. ' maxsize is required
  989. If ( Len(CStr(intMaxSize)) = 0 ) Then
  990. ValidateArguments = FALSE
  991. WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _
  992. L_MaximumSizeNotSpecified_ErrorMessage)
  993. component.VBPrintf L_TypeCreateUsage_Message, _
  994. Array(UCase(WScript.ScriptName))
  995. WScript.Quit(EXIT_INVALID_INPUT)
  996. End If
  997. ' volume name is required
  998. If (objVols.Count = 0) Then
  999. ValidateArguments = FALSE
  1000. WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _
  1001. L_VolumeNameNotSpecified_ErrorMessage)
  1002. component.VBPrintf L_TypeCreateUsage_Message, _
  1003. Array(UCase(WScript.ScriptName))
  1004. WScript.Quit(EXIT_INVALID_INPUT)
  1005. ' check if volume name is valid
  1006. ElseIf isValidDrive(objVols,intMainOption) Then
  1007. ValidateArguments = TRUE
  1008. End If
  1009. Case CONST_DELETE_OPTION
  1010. ' ONLY volume is required
  1011. If (objVols.Count = 0) Then
  1012. ValidateArguments = FALSE
  1013. WScript.Echo(L_InvalidSyntax_ErrorMessage & " " & _
  1014. L_VolumeNameNotSpecified_ErrorMessage)
  1015. component.VBPrintf L_TypeDeleteUsage_Message, _
  1016. Array(UCase(WScript.ScriptName))
  1017. WScript.Quit(EXIT_INVALID_INPUT)
  1018. ' check if volume name is valid
  1019. ElseIf isValidDrive(objVols,intMainOption) Then
  1020. ValidateArguments = TRUE
  1021. End If
  1022. ' Wild Card Character * is not allowed for /Delete option
  1023. If (objVols.Exists("*")) Then
  1024. ValidateArguments = FALSE
  1025. objVols.Remove "*"
  1026. WScript.Echo(L_InvalidInput_ErrorMessage)
  1027. WScript.Quit(EXIT_INVALID_INPUT)
  1028. End If
  1029. Case CONST_QUERY_OPTION
  1030. ' check if any format is specified.
  1031. If Len(strFormat) > 0 Then
  1032. ' only table, list and csv display formats allowed
  1033. ' L_PatternFormat_Text contains ^(table|list|csv)$
  1034. If CInt(component.matchPattern(L_PatternFormat_Text, strFormat)) = CONST_NO_MATCHES_FOUND Then
  1035. component.vbPrintf L_InvalidSyntax_ErrorMessage & " " & _
  1036. L_InvalidFormat_ErrorMessage, Array(strFormat)
  1037. component.VBPrintf L_TypeQueryUsage_Message, _
  1038. Array(UCase(WScript.ScriptName))
  1039. WScript.Quit(EXIT_INVALID_INPUT)
  1040. End If
  1041. End If
  1042. ' Validation to check if volume names are specified with Query Option:
  1043. If (intVolumes <> 0) Then
  1044. ValidateArguments = FALSE
  1045. WScript.Echo(L_InvalidSyntax_ErrorMessage)
  1046. component.VBPrintf L_TypeQueryUsage_Message, _
  1047. Array(UCase(WScript.ScriptName))
  1048. WScript.Quit(EXIT_INVALID_INPUT)
  1049. End If
  1050. Case Else
  1051. ' if intMainOption has some non-zero value means one operation is selected
  1052. If (intMainOption > 0) Then
  1053. ' -operation & volname together are valid
  1054. ValidateArguments = TRUE
  1055. Else
  1056. ValidateArguments = FALSE
  1057. WScript.Echo(L_InvalidInput_ErrorMessage)
  1058. WScript.Quit(EXIT_INVALID_INPUT)
  1059. End If
  1060. End Select
  1061. ' verify If required credentials given
  1062. If (((NOT IsEmpty(strUserName)) AND (IsEmpty(strMachine))) OR _
  1063. ((NOT IsEmpty(strPassword)) AND (IsEmpty(strUserName))) )Then
  1064. ValidateArguments = FALSE
  1065. WScript.Echo (L_InvalidCredentials_ErrorMessage)
  1066. WScript.Quit(EXIT_INVALID_INPUT)
  1067. End If
  1068. ' check if the machine name is specified using "\\" (UNC format)
  1069. If Left(strMachine,2) = UNC_FORMAT_SERVERNAME_PREFIX Then
  1070. If Len(strMachine) = 2 Then
  1071. WScript.Echo L_InvalidInput_ErrorMessage
  1072. WScript.Quit(EXIT_UNEXPECTED)
  1073. End If
  1074. ' remove the "\\" from the front
  1075. strMachine = Mid(strMachine,3,Len(strMachine))
  1076. End If
  1077. ' If password not specified with the user name, Then get it
  1078. If ((NOT IsEmpty(strUserName)) AND (IsEmpty(strPassword))) Then
  1079. strPassword = component.getPassword()
  1080. End If
  1081. End Function
  1082. '******************************************************************************
  1083. '* Function: isValidDrive
  1084. '*
  1085. '* Purpose: To check if the specified volume is valid or not
  1086. '*
  1087. '* Input:
  1088. '* [in] objVols object that store the volumes specified
  1089. '* [in] intMainOption the main option specified
  1090. '*
  1091. '* Output: Returns TRUE or FALSE
  1092. '*
  1093. '******************************************************************************
  1094. Function isValidDrive(ByRef objVols,ByVal intMainOption)
  1095. ON ERROR RESUME NEXT
  1096. Err.Clear
  1097. Dim intVolumes ' to count the no.of volumes specified
  1098. Dim arrVolume ' array to store the volumes specified
  1099. Dim i ' Loop variable
  1100. ' Initialization
  1101. intVolumes = CInt(objVols.Count)
  1102. arrVolume = objVols.Keys
  1103. isValidDrive = FALSE
  1104. i = 0
  1105. ' Check if the drive name is in correct Format [c-z]: or [C-Z]:
  1106. ' This has to be checked for each Drive specified - Do While Loop
  1107. Do While (i < intVolumes)
  1108. ' Volumes specified are valid for all option except Query
  1109. If intMainOption <> CONST_QUERY_OPTION Then
  1110. ' Valid volume is either '*' OR a letter followed by a colon (total length = 2)
  1111. If ((Len(arrVolume(i)) = 2) AND (InStr(arrVolume(i),chr(58)) = 2) OR arrVolume(i) = "*") Then
  1112. ' check if the volume name specified is in the format ^([c-zC-Z]:|\*)$
  1113. If CInt(component.matchPattern(L_VolumePatternFormat_Text,arrVolume(i))) = CONST_NO_MATCHES_FOUND Then
  1114. ' Invalid Volume Names or junk data is specified
  1115. component.VBPrintf L_InvalidVolumeName_ErrorMessage, _
  1116. Array(arrVolume(i))
  1117. isValidDrive = FALSE
  1118. ' remove the INVALID drive(s)
  1119. objVols.Remove arrVolume(i)
  1120. End If
  1121. Else
  1122. isValidDrive = FALSE
  1123. component.VBPrintf L_InvalidVolumeName_ErrorMessage, _
  1124. Array(arrVolume(i))
  1125. objVols.Remove arrVolume(i)
  1126. End If
  1127. ' check the number of valid drives specified
  1128. If objVols.Count = 0 Then
  1129. WScript.Quit(EXIT_INVALID_INPUT)
  1130. End If
  1131. Else
  1132. WScript.Echo(L_InvalidInput_ErrorMessage)
  1133. WScript.Quit (EXIT_INVALID_INPUT)
  1134. End If
  1135. isValidDrive = isValidDrive OR TRUE
  1136. i = i + 1
  1137. Loop
  1138. End Function
  1139. '******************************************************************************
  1140. '* Sub: ProcessChange
  1141. '*
  1142. '* Purpose: Processes the /Change option and displays the changed
  1143. '* details of the page file
  1144. '*
  1145. '* Input:
  1146. '* [in] strMachine machine to configure page files on
  1147. '* [in] strUserName user name to connect to the machine
  1148. '* [in] strPassword password for the user
  1149. '* [in] intIntSize the initial size for the page file
  1150. '* [in] intMaxSize the maximum size for the page file
  1151. '* [in] objVols the object containing volume names
  1152. '*
  1153. '* Output: Displays error message and quits if connection fails
  1154. '*
  1155. '******************************************************************************
  1156. Private Sub ProcessChange( ByVal strMachine, _
  1157. ByVal strUserName, _
  1158. ByVal strPassword, _
  1159. ByVal intIntSize, _
  1160. ByVal intMaxSize, _
  1161. ByVal objVols )
  1162. ON ERROR RESUME NEXT
  1163. Err.Clear
  1164. Dim intOldInitialSize ' to store the old intial size
  1165. Dim intOldMaximumSize ' to store the old maximum size
  1166. Dim arrVolume ' to store all the volumes specified
  1167. Dim intVolumes ' to store the no.of volumes specified
  1168. Dim strQuery ' to store the query for pagefiles
  1169. Dim strQueryDisk ' to store the query for disk
  1170. Dim strQueryComp ' to store the query for computersystem
  1171. Dim objService ' service object
  1172. Dim objInstance ' instance object
  1173. Dim objInst ' instance object
  1174. Dim objEnumerator ' collection set for query results
  1175. Dim objEnumforDisk ' collection set for query results
  1176. Dim objEnum ' collection set for query results
  1177. Dim blnBothSpecified ' flag to check if both initsize & maxsize are specified
  1178. Dim blnSuccessMsg ' flag to check if a SUCCESS message is generated
  1179. Dim intFreeSpace ' to store total free space
  1180. Dim intFreeDiskSpace ' to store free disk space
  1181. Dim intCurrentSize ' to store the current pagefile size
  1182. Dim intDiskSize ' to store the disk size for the specified disk
  1183. Dim intMemSize ' to store physical memory size
  1184. Dim intCrashDump ' to store the current crash dump setting value
  1185. Dim strReply ' to store the user reply
  1186. Dim strDriveName ' to store the drive name
  1187. Dim strHostName ' to store the host name
  1188. Dim intMaxSizeUB ' to store the upper bound for maximum size
  1189. Dim i ' loop variable
  1190. ' Establish a connection with the server.
  1191. If NOT component.wmiConnect(CONST_NAMESPACE_CIMV2 , _
  1192. strUserName , _
  1193. strPassword , _
  1194. strMachine , _
  1195. blnLocalConnection, _
  1196. objService ) Then
  1197. WScript.Echo(L_HintCheckConnection_Message)
  1198. WScript.Quit(EXIT_METHOD_FAIL)
  1199. End If
  1200. ' Initialize variables
  1201. i = 0
  1202. intFreeSpace = 0
  1203. intFreeDiskSpace = 0
  1204. intCurrentSize = 0
  1205. blnBothSpecified = FALSE
  1206. blnSuccessMsg = FALSE
  1207. intMaxSizeUB = 0
  1208. strQuery = "Select * From " & CLASS_PAGE_FILE_SETTING
  1209. If (objVols.Exists("*")) Then
  1210. Set objEnumerator = objService.ExecQuery(strQuery, "WQL", 0, null)
  1211. For each objInstance in objEnumerator
  1212. strDriveName = Mid(objInstance.Name,1,2)
  1213. If NOT objVols.Exists (LCase(strDriveName)) Then
  1214. objVols.add LCase(strDriveName), -1
  1215. End If
  1216. Next
  1217. objVols.remove "*"
  1218. End If
  1219. intVolumes = objVols.Count
  1220. arrVolume = objVols.keys
  1221. ' get the host Name - used to get Crash Dump Settings
  1222. strQueryComp = "Select * From " & CLASS_COMPUTER_SYSTEM
  1223. Set objEnum = objService.ExecQuery(strQueryComp, "WQL", 0, null)
  1224. ' check for any errors
  1225. If Err.Number Then
  1226. Err.Clear
  1227. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  1228. WScript.Quit(EXIT_QUERY_FAIL)
  1229. End If
  1230. For each objInst in objEnum
  1231. If NOT ISEmpty(objInst.Name) Then
  1232. strHostName = objInst.Name
  1233. Else
  1234. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  1235. WScript.Quit(EXIT_QUERY_FAIL)
  1236. End If
  1237. Next
  1238. ' check if initsize and maxsize both are specified
  1239. If (Len(intIntSize) > 0 AND Len(intMaxSize) > 0) Then
  1240. blnBothSpecified = TRUE
  1241. End If
  1242. ' check if no page files exist on the system.
  1243. strQuery = "Select * From " & CLASS_PAGE_FILE_SETTING
  1244. Set objEnumerator = objService.ExecQuery(strQuery, "WQL", 0, null)
  1245. If (objEnumerator.Count = 0) Then
  1246. WScript.Echo(L_NoPageFiles_Message)
  1247. WScript.Quit(EXIT_UNEXPECTED)
  1248. End If
  1249. ' release the object for re-use.
  1250. Set objEnumerator = nothing
  1251. Do While( i < intVolumes )
  1252. ' check if its a valid drive/volume - check from Win32_LogicalDisk
  1253. strQueryDisk = "Select * From " & CLASS_LOGICAL_DISK & _
  1254. " where DriveType = " & DRIVE_TYPE & " and DeviceID = '" & arrVolume(i) & "'"
  1255. Set objEnumforDisk = objService.ExecQuery(strQueryDisk, "WQL", 0, null)
  1256. If objEnumforDisk.Count > 0 Then
  1257. strQuery = "Select * From " & CLASS_PAGE_FILE_SETTING
  1258. strQuery = strQuery & " where NAME = '" & arrVolume(i) & _
  1259. "\" & PAGEFILE_DOT_SYS & "'"
  1260. Set objEnumerator = objService.ExecQuery(strQuery, "WQL", 0, null)
  1261. ' check for any errors
  1262. If Err.Number Then
  1263. Err.Clear
  1264. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  1265. WScript.Quit(EXIT_QUERY_FAIL)
  1266. End If
  1267. ' check if a page file exists on the specified volume
  1268. If (objEnumerator.Count > 0) Then
  1269. For each objInstance in objEnumerator
  1270. ' check for system managed pagefiles
  1271. If (objInstance.InitialSize = 0 AND objInstance.MaximumSize = 0) Then
  1272. component.VBPrintf L_SystemManagedSize_ErrorMessage, _
  1273. Array(UCase(arrVolume(i)))
  1274. Else
  1275. strDriveName = Mid(objInstance.Name,1,2)
  1276. If NOT blnBothSpecified Then
  1277. ' check if initsize is given
  1278. If (intIntSize > 0) Then
  1279. ' Check if initsize is greater than 2 MB
  1280. If CLng(intIntSize) >= CLng(INITIAL_SIZE_LB) Then
  1281. ' check for overflows
  1282. If Err.Number Then
  1283. Err.Clear
  1284. ' get the upper bound allowed for maximum size
  1285. intMaxSizeUB = getMaxSizeUB(objService)
  1286. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1287. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1288. WScript.Quit(EXIT_INVALID_INPUT)
  1289. End If
  1290. ' get the drive name first
  1291. strDriveName = Mid(objInstance.Name,1,2)
  1292. ' get the free space available on the specified disk
  1293. intFreeDiskSpace = getFreeSpaceOnDisk(strDriveName,objService)
  1294. ' get the current pagefile size
  1295. intCurrentSize = getCurrentPageFileSize(objService,objInstance)
  1296. ' get the total free space
  1297. If Len(intCurrentSize) > 0 Then
  1298. intFreeSpace = intFreeDiskSpace + intCurrentSize
  1299. Else
  1300. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  1301. WScript.Quit(EXIT_QUERY_FAIL)
  1302. End If
  1303. ' Check if it is greater than free disk space
  1304. If CLng(intIntSize) > CLng(intFreeSpace) Then
  1305. ' check for overflows
  1306. If Err.Number Then
  1307. Err.Clear
  1308. ' get the upper bound allowed for maximum size
  1309. intMaxSizeUB = getMaxSizeUB(objService)
  1310. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1311. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1312. WScript.Quit(EXIT_INVALID_INPUT)
  1313. End If
  1314. WScript.Echo(NotEnoughSpaceErrorMessage)
  1315. WScript.Quit(EXIT_INVALID_INPUT)
  1316. Else
  1317. If CLng(intIntSize) > CLng(intFreeSpace) - 5 Then
  1318. ' check for overflows
  1319. If Err.Number Then
  1320. Err.Clear
  1321. WScript.Echo(L_InvalidInput_ErrorMessage)
  1322. WScript.Quit(EXIT_INVALID_INPUT)
  1323. End If
  1324. WScript.Echo(AtLeastFiveMBErrorMessage)
  1325. WScript.Quit(EXIT_INVALID_INPUT)
  1326. Else
  1327. ' only one of initsize, maxsize is specified
  1328. ' check if the specified initsize is less than existing maxsize
  1329. If (CInt(intIntSize) <= objInstance.MaximumSize) Then
  1330. ' get the crash dump setting value
  1331. intCrashDump = GetCrashDumpSetting(strUserName,strPassword,strMachine)
  1332. ' get the Physical Memory Size
  1333. intMemSize = GetPhysicalMemorySize(strHostName,objService)
  1334. ' If the user has selected "yes" for the warning message
  1335. If isCrashDumpValueSet(intCrashDump,intIntSize,intMemSize,arrVolume(i)) Then
  1336. ' Check if initsize is same as the present value
  1337. If (CInt(intIntSize) <> objInstance.InitialSize) Then
  1338. ' store the old initsize value
  1339. intOldInitialSize = objInstance.InitialSize
  1340. ' set the new initsize
  1341. objInstance.InitialSize = intIntSize
  1342. objInstance.Put_(CONST_WBEM_FLAG)
  1343. If Err.Number Then
  1344. Err.Clear
  1345. WScript.Echo(L_UpdateFailed_ErrorMessage)
  1346. WScript.Quit(EXIT_INVALID_INPUT)
  1347. End If
  1348. component.VBPrintf ChangeIntSuccessMessage, _
  1349. Array(UCase(arrVolume(i)),CInt(intOldInitialSize),CInt(intIntSize))
  1350. blnSuccessMsg = TRUE
  1351. Else
  1352. component.VBPrintf ChangeIntSkippingMessage, Array(UCase(arrVolume(i)))
  1353. End If
  1354. End If
  1355. Else
  1356. ' get the upper bound allowed for maximum size
  1357. intMaxSizeUB = getMaxSizeUB(objService)
  1358. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1359. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1360. End If
  1361. End If
  1362. End If
  1363. Else
  1364. ' get the upper bound allowed for maximum size
  1365. intMaxSizeUB = getMaxSizeUB(objService)
  1366. component.VBPrintf InitialSizeRangeErrorMessage, _
  1367. Array(intMaxSizeUB)
  1368. WScript.Quit(EXIT_INVALID_INPUT)
  1369. End If
  1370. Else
  1371. ' Check if initsize specified as 0
  1372. If Len(intIntSize) > 0 Then
  1373. ' get the upper bound allowed for maximum size
  1374. intMaxSizeUB = getMaxSizeUB(objService)
  1375. component.VBPrintf InitialSizeRangeErrorMessage, _
  1376. Array(intMaxSizeUB)
  1377. WScript.Quit(EXIT_INVALID_INPUT)
  1378. End If
  1379. End If ' initsize checked
  1380. ' check if maxsize is given
  1381. If (intMaxSize > 0) Then
  1382. ' get the free space available on the specified disk
  1383. intFreeDiskSpace = getFreeSpaceOnDisk(strDriveName,objService)
  1384. ' get the current pagefile size
  1385. intCurrentSize = getCurrentPageFileSize(objService,objInstance)
  1386. ' get the total free space
  1387. If Len(intCurrentSize) > 0 Then
  1388. intFreeSpace = intFreeDiskSpace + intCurrentSize
  1389. Else
  1390. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  1391. WScript.Quit(EXIT_QUERY_FAIL)
  1392. End If
  1393. ' Get the Disk Size for the specified drive
  1394. intDiskSize = GetDiskSize(arrVolume(i),objService)
  1395. ' check if maxsize is more than initsize
  1396. If (CLng(intMaxSize) > CLng(intDiskSize)) Then
  1397. ' check for overflows
  1398. If Err.Number Then
  1399. Err.Clear
  1400. ' get the upper bound allowed for maximum size
  1401. intMaxSizeUB = getMaxSizeUB(objService)
  1402. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1403. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1404. WScript.Quit(EXIT_INVALID_INPUT)
  1405. End If
  1406. component.VBPrintf DiskTooSmallErrorMessage, Array(UCase(arrVolume(i)))
  1407. Else
  1408. If (CLng(intMaxSize) > CLng(intFreeSpace)) Then
  1409. ' check for overflows
  1410. If Err.Number Then
  1411. Err.Clear
  1412. WScript.Echo(L_InvalidInput_ErrorMessage)
  1413. WScript.Quit(EXIT_INVALID_INPUT)
  1414. End If
  1415. component.VBPrintf GrowsToFreeSpaceWarningMessage, _
  1416. Array(UCase(arrVolume(i)),intFreeSpace)
  1417. strReply = getReply()
  1418. If Trim(LCase(strReply)) = L_UserReplyYes_Text Then
  1419. ' set the maxsize to be the free space on disk
  1420. intMaxSize = intFreeSpace
  1421. ' check if the given maxsize is greater than the existing initial size.
  1422. If (CInt(intMaxSize) >= objInstance.InitialSize) Then
  1423. If (CInt(intMaxSize) <> objInstance.MaximumSize) Then
  1424. intOldMaximumSize = objInstance.MaximumSize
  1425. objInstance.MaximumSize = intMaxSize
  1426. objInstance.Put_(CONST_WBEM_FLAG)
  1427. If Err.Number Then
  1428. Err.Clear
  1429. WScript.Echo(L_UpdateFailed_ErrorMessage)
  1430. WScript.Quit(EXIT_INVALID_INPUT)
  1431. End If
  1432. component.VBPrintf ChangeMaxSuccessMessage, _
  1433. Array(UCase(arrVolume(i)),CInt(intOldMaximumSize),CInt(intMaxSize))
  1434. blnSuccessMsg = TRUE
  1435. Else
  1436. component.VBPrintf ChangeMaxSkippingMessage, Array(UCase(arrVolume(i)))
  1437. End If
  1438. Else
  1439. ' get the upper bound allowed for maximum size
  1440. intMaxSizeUB = getMaxSizeUB(objService)
  1441. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1442. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1443. End If
  1444. ElseIf LCase(strReply) = L_UserReplyNo_Text Then
  1445. WScript.Quit(EXIT_SUCCESS)
  1446. Else
  1447. WScript.Echo(L_InvalidInput_ErrorMessage)
  1448. WScript.Quit (EXIT_INVALID_INPUT)
  1449. End If
  1450. Else
  1451. If (CInt(intMaxSize) >= objInstance.InitialSize) Then
  1452. If (CInt(intMaxSize) <> objInstance.MaximumSize) Then
  1453. intOldMaximumSize = objInstance.MaximumSize
  1454. objInstance.MaximumSize = intMaxSize
  1455. objInstance.Put_(CONST_WBEM_FLAG)
  1456. If Err.Number Then
  1457. Err.Clear
  1458. WScript.Echo(L_UpdateFailed_ErrorMessage)
  1459. WScript.Quit(EXIT_INVALID_INPUT)
  1460. End If
  1461. component.VBPrintf ChangeMaxSuccessMessage, _
  1462. Array(UCase(arrVolume(i)),CInt(intOldMaximumSize),CInt(intMaxSize))
  1463. blnSuccessMsg = TRUE
  1464. Else
  1465. component.VBPrintf ChangeMaxSkippingMessage, Array(UCase(arrVolume(i)))
  1466. End If
  1467. Else
  1468. ' get the upper bound allowed for maximum size
  1469. intMaxSizeUB = getMaxSizeUB(objService)
  1470. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1471. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1472. End If
  1473. End If
  1474. End If
  1475. Else
  1476. ' Check if maxsize specified as 0
  1477. If Len(intMaxSize) > 0 Then
  1478. ' get the upper bound allowed for maximum size
  1479. intMaxSizeUB = getMaxSizeUB(objService)
  1480. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1481. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1482. End If
  1483. End If ' maxsize checked
  1484. Else
  1485. ' Case when both initsize and maxsize are selected
  1486. ' check if maxsize is greater than initsize
  1487. ' this will detect any overflow problems, if any
  1488. If CLng(intIntSize) > CLng(intMaxSize) Then
  1489. ' check for overflows and clear the error
  1490. If Err.Number Then Err.Clear
  1491. ' get the upper bound allowed for maximum size
  1492. intMaxSizeUB = getMaxSizeUB(objService)
  1493. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1494. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1495. WScript.Quit(EXIT_INVALID_INPUT)
  1496. End If
  1497. If (intIntSize > 0) Then
  1498. ' Check if initsize is greater than 2 MB
  1499. If CLng(intIntSize) >= CLng(INITIAL_SIZE_LB) Then
  1500. ' check for overflows
  1501. If Err.Number Then
  1502. Err.Clear
  1503. ' get the upper bound allowed for maximum size
  1504. intMaxSizeUB = getMaxSizeUB(objService)
  1505. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1506. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1507. WScript.Quit(EXIT_INVALID_INPUT)
  1508. End If
  1509. ' get the free space available on the specified disk
  1510. intFreeDiskSpace = getFreeSpaceOnDisk(strDriveName,objService)
  1511. ' get the current pagefile size
  1512. intCurrentSize = getCurrentPageFileSize(objService,objInstance)
  1513. ' get the total free space
  1514. If Len(intCurrentSize) > 0 Then
  1515. intFreeSpace = intFreeDiskSpace + intCurrentSize
  1516. Else
  1517. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  1518. WScript.Quit(EXIT_QUERY_FAIL)
  1519. End If
  1520. ' check if it is greater than free disk space
  1521. If CLng(intIntSize) > CLng(intFreeSpace) Then
  1522. ' check for overflows
  1523. If Err.Number Then
  1524. Err.Clear
  1525. ' get the upper bound allowed for maximum size
  1526. intMaxSizeUB = getMaxSizeUB(objService)
  1527. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1528. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1529. WScript.Quit(EXIT_INVALID_INPUT)
  1530. End If
  1531. WScript.Echo(NotEnoughSpaceErrorMessage)
  1532. WScript.Quit(EXIT_INVALID_INPUT)
  1533. End If
  1534. If CLng(intIntSize) > CLng(intFreeSpace) - 5 Then
  1535. ' check for overflows
  1536. If Err.Number Then
  1537. Err.Clear
  1538. WScript.Echo(L_InvalidInput_ErrorMessage)
  1539. WScript.Quit(EXIT_INVALID_INPUT)
  1540. End If
  1541. WScript.Echo(AtLeastFiveMBErrorMessage)
  1542. WScript.Quit(EXIT_INVALID_INPUT)
  1543. Else
  1544. ' get the crash dump setting value
  1545. intCrashDump = GetCrashDumpSetting(strUserName,strPassword,strMachine)
  1546. ' get the Physical Memory Size
  1547. intMemSize = GetPhysicalMemorySize(strHostName,objService)
  1548. ' If the user has selected "yes" for the warning message
  1549. If isCrashDumpValueSet(intCrashDump,intIntSize,intMemSize,arrVolume(i)) Then
  1550. ' store the old initsize value
  1551. intOldInitialSize = objInstance.InitialSize
  1552. ' set the new initsize
  1553. objInstance.InitialSize = intIntSize
  1554. ' check if maxsize is given
  1555. If (intMaxSize > 0) Then
  1556. ' Get the Disk Size for the specified drive
  1557. intDiskSize = GetDiskSize(arrVolume(i),objService)
  1558. ' check if maxsize is more than initsize
  1559. If (CLng(intMaxSize) > CLng(intDiskSize)) Then
  1560. ' check for overflows
  1561. If Err.Number Then
  1562. Err.Clear
  1563. ' get the upper bound allowed for maximum size
  1564. intMaxSizeUB = getMaxSizeUB(objService)
  1565. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1566. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1567. WScript.Quit(EXIT_INVALID_INPUT)
  1568. End If
  1569. component.VBPrintf DiskTooSmallErrorMessage, _
  1570. Array(UCase(arrVolume(i)))
  1571. Else
  1572. If (CLng(intMaxSize) > CLng(intFreeSpace)) Then
  1573. ' check for overflows
  1574. If Err.Number Then
  1575. Err.Clear
  1576. WScript.Echo(L_InvalidInput_ErrorMessage)
  1577. WScript.Quit(EXIT_INVALID_INPUT)
  1578. End If
  1579. component.VBPrintf GrowsToFreeSpaceWarningMessage, _
  1580. Array(UCase(arrVolume(i)),intFreeSpace)
  1581. strReply = getReply()
  1582. If Trim(LCase(strReply)) = L_UserReplyYes_Text Then
  1583. ' set the maxsize to be the free space on disk
  1584. intMaxSize = intFreeSpace
  1585. intOldMaximumSize = objInstance.MaximumSize
  1586. objInstance.MaximumSize = intMaxSize
  1587. If ( CInt(intIntSize) <> intOldInitialSize ) Then
  1588. objInstance.Put_(CONST_WBEM_FLAG)
  1589. If Err.Number Then
  1590. Err.Clear
  1591. WScript.Echo(L_UpdateFailed_ErrorMessage)
  1592. WScript.Quit(EXIT_INVALID_INPUT)
  1593. End If
  1594. component.VBPrintf ChangeIntSuccessMessage, _
  1595. Array(UCase(arrVolume(i)),CInt(intOldInitialSize),CInt(intIntSize))
  1596. blnSuccessMsg = TRUE
  1597. Else
  1598. component.VBPrintf ChangeIntSkippingMessage, _
  1599. Array(UCase(arrVolume(i)))
  1600. End If
  1601. If (CInt(intMaxSize) <> intOldMaximumSize) Then
  1602. objInstance.Put_(CONST_WBEM_FLAG)
  1603. If Err.Number Then
  1604. Err.Clear
  1605. WScript.Echo(L_UpdateFailed_ErrorMessage)
  1606. WScript.Quit(EXIT_INVALID_INPUT)
  1607. End If
  1608. component.VBPrintf ChangeMaxSuccessMessage, _
  1609. Array(UCase(arrVolume(i)),CInt(intOldMaximumSize),CInt(intMaxSize))
  1610. blnSuccessMsg = TRUE
  1611. Else
  1612. component.VBPrintf ChangeMaxSkippingMessage, _
  1613. Array(UCase(arrVolume(i)))
  1614. End If
  1615. ElseIf LCase(strReply) = L_UserReplyNo_Text Then
  1616. WScript.Quit(EXIT_SUCCESS)
  1617. Else
  1618. WScript.Echo(L_InvalidInput_ErrorMessage)
  1619. WScript.Quit (EXIT_INVALID_INPUT)
  1620. End If
  1621. Else
  1622. intOldMaximumSize = objInstance.MaximumSize
  1623. objInstance.MaximumSize = intMaxSize
  1624. objInstance.Put_(CONST_WBEM_FLAG)
  1625. If Err.Number Then
  1626. Err.Clear
  1627. WScript.Echo(L_UpdateFailed_ErrorMessage)
  1628. WScript.Quit(EXIT_INVALID_INPUT)
  1629. End If
  1630. If (CInt(intIntSize) <> intOldInitialSize ) Then
  1631. component.VBPrintf ChangeIntSuccessMessage, _
  1632. Array(UCase(arrVolume(i)),CInt(intOldInitialSize),CInt(intIntSize))
  1633. blnSuccessMsg = TRUE
  1634. Else
  1635. component.VBPrintf ChangeIntSkippingMessage, Array(UCase(arrVolume(i)))
  1636. End If
  1637. If (CInt(intMaxSize) <> intOldMaximumSize) Then
  1638. component.VBPrintf ChangeMaxSuccessMessage, _
  1639. Array(UCase(arrVolume(i)),CInt(intOldMaximumSize),CInt(intMaxSize))
  1640. blnSuccessMsg = TRUE
  1641. Else
  1642. component.VBPrintf ChangeMaxSkippingMessage, Array(UCase(arrVolume(i)))
  1643. End If
  1644. End If
  1645. End If
  1646. Else
  1647. ' Check if maxsize specified as 0
  1648. If Len(intMaxSize) > 0 Then
  1649. ' get the upper bound allowed for maximum size
  1650. intMaxSizeUB = getMaxSizeUB(objService)
  1651. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1652. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1653. End If
  1654. End If ' maxsize checked
  1655. End If
  1656. End If
  1657. Else
  1658. ' get the upper bound allowed for maximum size
  1659. intMaxSizeUB = getMaxSizeUB(objService)
  1660. component.VBPrintf InitialSizeRangeErrorMessage, _
  1661. Array(intMaxSizeUB)
  1662. WScript.Quit(EXIT_INVALID_INPUT)
  1663. End If
  1664. Else
  1665. ' Check if initsize specified as 0
  1666. If Len(intIntSize) > 0 Then
  1667. ' get the upper bound allowed for maximum size
  1668. intMaxSizeUB = getMaxSizeUB(objService)
  1669. component.VBPrintf InitialSizeRangeErrorMessage, _
  1670. Array(intMaxSizeUB)
  1671. WScript.Quit(EXIT_INVALID_INPUT)
  1672. End If
  1673. End If ' initsize checked
  1674. End If
  1675. End If
  1676. Next
  1677. Else
  1678. component.VBPrintf L_PageFileDoesNotExist_ErrorMessage, _
  1679. Array(UCase(arrVolume(i)))
  1680. End If
  1681. Else
  1682. ' the drive does not exist
  1683. component.VBPrintf L_InvalidVolumeName_ErrorMessage, _
  1684. Array(UCase(arrVolume(i)))
  1685. ' remove the drive name from the valid drives list
  1686. objVols.Remove arrVolume(i)
  1687. ' decrement the loop count
  1688. i = i - 1
  1689. ' check for the no.of valid drive names from the specified list.
  1690. If Cint(objVols.Count) = 0 Then
  1691. WScript.Quit(EXIT_INVALID_INPUT)
  1692. Else
  1693. intVolumes = objVols.Count
  1694. arrVolume = objVols.keys
  1695. End If
  1696. End If
  1697. i = i + 1
  1698. Loop
  1699. If blnSuccessMsg = TRUE then
  1700. WScript.Echo L_RestartComputer_Message
  1701. End If
  1702. End Sub
  1703. '******************************************************************************
  1704. '* Sub: ProcessCreate
  1705. '*
  1706. '* Purpose: Creates new page files with the given specifications
  1707. '*
  1708. '* Input:
  1709. '* [in] strMachine machine to configure page files on
  1710. '* [in] strUserName user name to connect to the machine
  1711. '* [in] strPassword password for the user
  1712. '* [in] intIntSize the initial size for the page file
  1713. '* [in] intMaxSize the maximum size for the page file
  1714. '* [in] objVols the object containing volume names
  1715. '*
  1716. '* Output: Displays error message and quits if connection fails
  1717. '*
  1718. '******************************************************************************
  1719. Private Sub ProcessCreate( ByVal strMachine, _
  1720. ByVal strUserName, _
  1721. ByVal strPassword, _
  1722. ByVal intIntSize, _
  1723. ByVal intMaxSize, _
  1724. ByVal objVols )
  1725. ON ERROR RESUME NEXT
  1726. Err.Clear
  1727. Dim arrVolume ' to store all the volumes specified
  1728. Dim intVolumes ' to store the no.of volumes specified
  1729. Dim strQuery ' to store the query for pagefiles
  1730. Dim strQueryDisk ' to store the query for disk
  1731. Dim strQueryComp ' to store the query for getting host name
  1732. Dim objService ' service object
  1733. Dim objInst ' instance object
  1734. Dim objInstance ' instance object
  1735. Dim objNewInstance ' instance object
  1736. Dim objEnum ' collection object for query results
  1737. Dim objEnumforDisk ' collection object for query results
  1738. Dim blnSuccessMsg ' flag to check if a SUCCESS message is generated
  1739. Dim intFreeSpace ' to store total free space
  1740. Dim intFreeDiskSpace ' to store free disk space
  1741. Dim intCurrentSize ' to store the current pagefile size
  1742. Dim intDiskSize ' to store the disk size for the specified disk
  1743. Dim intMemSize ' to store physical memory size
  1744. Dim intCrashDump ' to store the current crash dump setting value
  1745. Dim strReply ' to store the user reply
  1746. Dim strHostName ' to store the host name
  1747. Dim intMaxSizeUB ' to store the upper bound for maximum size
  1748. Dim i ' Loop variable
  1749. ' variables used only if * is specified
  1750. Dim objEnumerator ' collection object for query results
  1751. i = 0
  1752. intFreeSpace = 0
  1753. intFreeDiskSpace = 0
  1754. intCurrentSize = 0
  1755. intMaxSizeUB = 0
  1756. ' intIntSize = CLng(intIntSize)
  1757. ' intMaxSize = CLng(intMaxSize)
  1758. blnSuccessMsg = FALSE
  1759. If NOT component.wmiConnect(CONST_NAMESPACE_CIMV2 , _
  1760. strUserName , _
  1761. strPassword , _
  1762. strMachine , _
  1763. blnLocalConnection , _
  1764. objService ) Then
  1765. WScript.Echo(L_HintCheckConnection_Message)
  1766. WScript.Quit(EXIT_METHOD_FAIL)
  1767. End If
  1768. If (objVols.Exists("*")) Then
  1769. ' build the query
  1770. intVolumes = 0
  1771. ' get all the drive names with drive type = 3 (other than floppy drive & CDROM Drive)
  1772. strQuery = "Select DeviceID From " & CLASS_LOGICAL_DISK & _
  1773. " where DriveType = " & DRIVE_TYPE
  1774. ' execute the query
  1775. Set objEnumerator = objService.ExecQuery(strQuery, "WQL", 48, null)
  1776. ' check for any errors
  1777. If Err.Number Then
  1778. Err.Clear
  1779. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  1780. WScript.Quit(EXIT_QUERY_FAIL)
  1781. End If
  1782. For each objInstance in objEnumerator
  1783. ' check if the volumename is not an alias name and neither a mapped drive.
  1784. If IsValidPhysicalDrive(objService, objInstance.DeviceID) Then
  1785. ' check if the volume name is specified more than once.
  1786. If NOT objVols.Exists(LCase(objInstance.DeviceID)) Then
  1787. objVols.Add LCase(objInstance.DeviceID),-1
  1788. End If
  1789. End If
  1790. Next
  1791. ' Remove * from objVols after adding the drives to the object.
  1792. objVols.Remove "*"
  1793. End If
  1794. intVolumes = objVols.Count
  1795. arrVolume = objVols.Keys
  1796. ' Get the host Name - used to get Crash Dump Settings
  1797. strQueryComp = "Select * From " & CLASS_COMPUTER_SYSTEM
  1798. Set objEnum = objService.ExecQuery(strQueryComp, "WQL", 0, null)
  1799. ' check for any errors
  1800. If Err.Number Then
  1801. Err.Clear
  1802. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  1803. WScript.Quit(EXIT_QUERY_FAIL)
  1804. End If
  1805. For each objInst in objEnum
  1806. If NOT ISEmpty(objInst.Name) Then
  1807. strHostName = objInst.Name
  1808. Else
  1809. WSCript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  1810. WScript.Quit(EXIT_QUERY_FAIL)
  1811. End If
  1812. Next
  1813. ' No wild Cards Specified
  1814. Do While( i < intVolumes )
  1815. strQueryDisk = "Select * From " & CLASS_LOGICAL_DISK & _
  1816. " where DriveType = " & DRIVE_TYPE & " and DeviceID = '" & arrVolume(i) & "'"
  1817. Set objEnumforDisk = objService.ExecQuery(strQueryDisk, "WQL", 0, null)
  1818. strQuery = "Select * From " & CLASS_PAGE_FILE_SETTING & _
  1819. " where Name = '" & arrVolume(i) & "\" & PAGEFILE_DOT_SYS & "'"
  1820. Set objEnum = objService.ExecQuery(strQuery, "WQL", 0, null)
  1821. ' If valid drive and pagefile exists on that drive
  1822. If (objEnumforDisk.Count = 0 AND objEnum.Count = 0 ) Then
  1823. ' the drive does not exist
  1824. component.VBPrintf L_InvalidVolumeName_ErrorMessage, _
  1825. Array(UCase(arrVolume(i)))
  1826. ' remove the drive name from the valid drives list
  1827. objVols.Remove arrVolume(i)
  1828. ' decrement the loop count
  1829. i = i - 1
  1830. ' check for the no.of valid drive names from the specified list.
  1831. If Cint(objVols.Count) = 0 Then
  1832. WScript.Quit(EXIT_INVALID_INPUT)
  1833. Else
  1834. intVolumes = objVols.Count
  1835. arrVolume = objVols.keys
  1836. End If
  1837. Else
  1838. ' SKIP - if at least one instance is found then dont create a new instance
  1839. If (objEnumforDisk.Count = 1 AND objEnum.Count = 1) Then
  1840. component.VBPrintf L_CreateSkipping_Message, _
  1841. Array(UCase(arrVolume(i)))
  1842. Else
  1843. ' check if the volumename is an alias name or a mapped drive
  1844. If NOT IsValidPhysicalDrive(objService, arrVolume(i)) Then
  1845. component.VBPrintf L_InvalidPhysicalDrive_ErrorMessage, _
  1846. Array(UCase(arrVolume(i)))
  1847. Else
  1848. ' set the security privilege to allow pagefile creation
  1849. objService.Security_.Privileges.AddAsString("SeCreatePagefilePrivilege")
  1850. If Err.Number then
  1851. Err.Clear
  1852. WScript.Echo("ERROR: Failed to set the security privilege.")
  1853. WScript.Quit(EXIT_METHOD_FAIL)
  1854. End If
  1855. Set objInstance = objService.Get(CLASS_PAGE_FILE_SETTING)
  1856. ' check for any errors
  1857. If Err.Number Then
  1858. Err.Clear
  1859. WScript.Echo(L_CannotCreate_ErrorMessage)
  1860. WScript.Quit(EXIT_METHOD_FAIL)
  1861. End If
  1862. Set objNewInstance = objInstance.SpawnInstance_
  1863. ' check for any errors
  1864. If Err.Number Then
  1865. Err.Clear
  1866. WScript.Echo(L_CannotCreate_ErrorMessage)
  1867. WScript.Quit(EXIT_INVALID_INPUT)
  1868. End If
  1869. ' append the filename to the volume name
  1870. objNewInstance.Name = UCase(arrVolume(i)) & PAGEFILE_DOT_SYS
  1871. ' check if maxsize is greater than initsize
  1872. ' this will detect any overflow problems, if any
  1873. If ( CLng(intIntSize) > CLng(intMaxSize) ) Then
  1874. ' check for overflows and clear the error
  1875. If Err.Number Then Err.Clear
  1876. ' get the upper bound allowed for maximum size
  1877. intMaxSizeUB = getMaxSizeUB(objService)
  1878. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1879. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1880. WScript.Quit(EXIT_INVALID_INPUT)
  1881. End If
  1882. ' Check the initial size with the free space on the disk
  1883. If CLng(intIntSize) >= CLng(INITIAL_SIZE_LB) Then
  1884. ' check for overflows
  1885. If Err.Number Then
  1886. Err.Clear
  1887. WScript.Echo(L_InvalidInput_ErrorMessage)
  1888. WScript.Quit(EXIT_INVALID_INPUT)
  1889. End If
  1890. ' get the free space on the specified disk
  1891. intFreeDiskSpace = getFreeSpaceOnDisk(arrVolume(i),objService)
  1892. ' get the current pagefile size
  1893. intCurrentSize = getCurrentPageFileSize(objService,objInstance)
  1894. ' get the total free space
  1895. ' Since its a new instance the current size will
  1896. ' NOT be available. So the initial size is taken
  1897. ' into considerarion for calculating the total
  1898. ' free space.
  1899. intFreeSpace = intFreeDiskSpace + intIntSize
  1900. ' Check if it greater than free disk space
  1901. If CLng(intIntSize) > CLng(intFreeSpace) Then
  1902. ' check for overflows
  1903. If Err.Number Then
  1904. Err.Clear
  1905. WScript.Echo(L_InvalidInput_ErrorMessage)
  1906. WScript.Quit(EXIT_INVALID_INPUT)
  1907. End If
  1908. WScript.Echo(NotEnoughSpaceErrorMessage)
  1909. WScript.Quit(EXIT_INVALID_INPUT)
  1910. End If
  1911. If CLng(intIntSize) > CLng(intFreeSpace) - 5 Then
  1912. ' check for overflows
  1913. If Err.Number Then
  1914. Err.Clear
  1915. WScript.Echo(L_InvalidInput_ErrorMessage)
  1916. WScript.Quit(EXIT_INVALID_INPUT)
  1917. End If
  1918. WScript.Echo(AtLeastFiveMBErrorMessage)
  1919. WScript.Quit(EXIT_INVALID_INPUT)
  1920. End If
  1921. ' get the crash dump setting value
  1922. intCrashDump = GetCrashDumpSetting(strUserName,strPassword,strMachine)
  1923. ' get the Physical Memory Size
  1924. intMemSize = GetPhysicalMemorySize(strHostName,objService)
  1925. ' check if the user has selected "yes" for the warning message
  1926. If isCrashDumpValueSet(intCrashDump,intIntSize,intMemSize,arrVolume(i)) Then
  1927. objNewInstance.InitialSize = CInt(intIntSize)
  1928. ' Get the Disk Size for the specified drive
  1929. intDiskSize = GetDiskSize(arrVolume(i),objService)
  1930. If (CLng(intMaxSize) > CLng(intDiskSize)) Then
  1931. ' check for overflows
  1932. If Err.Number Then
  1933. Err.Clear
  1934. ' get the upper bound allowed for maximum size
  1935. intMaxSizeUB = getMaxSizeUB(objService)
  1936. component.VBPrintf InsufficientMaxSizeErrorMessage, _
  1937. Array( UCase(arrVolume(i)) , intMaxSizeUB )
  1938. WScript.Quit(EXIT_INVALID_INPUT)
  1939. End If
  1940. component.VBPrintf DiskTooSmallErrorMessage, _
  1941. Array(UCase(arrVolume(i)))
  1942. Else
  1943. If (CLng(intMaxSize) > CLng(intFreeSpace)) Then
  1944. ' check for overflows
  1945. If Err.Number Then
  1946. Err.Clear
  1947. WScript.Echo(L_InvalidInput_ErrorMessage)
  1948. WScript.Quit(EXIT_INVALID_INPUT)
  1949. End If
  1950. component.VBPrintf GrowsToFreeSpaceWarningMessage, _
  1951. Array(UCase(arrVolume(i)),intFreeSpace)
  1952. strReply = getReply()
  1953. If Trim(LCase(strReply)) = L_UserReplyYes_Text Then
  1954. ' maxsize can grow only to the free disk space available.
  1955. ' set the maxsize to the free space on disk.
  1956. intMaxSize = intFreeSpace
  1957. objNewInstance.MaximumSize = intMaxSize
  1958. objNewInstance.Put_(CONST_WBEM_FLAG)
  1959. If Err.Number Then
  1960. Err.Clear
  1961. WScript.Echo(L_CannotCreate_ErrorMessage)
  1962. WScript.Quit(EXIT_INVALID_INPUT)
  1963. End If
  1964. component.VBPrintf CreateSuccessMessage, _
  1965. Array(CInt(intIntSize),CInt(intMaxSize),UCase(arrVolume(i)))
  1966. blnSuccessMsg = TRUE
  1967. ElseIf LCase(strReply) = L_UserReplyNo_Text Then
  1968. WScript.Quit(EXIT_SUCCESS)
  1969. Else
  1970. WScript.Echo(L_InvalidInput_ErrorMessage)
  1971. WScript.Quit (EXIT_INVALID_INPUT)
  1972. End If
  1973. Else
  1974. objNewInstance.MaximumSize = CInt(intMaxSize)
  1975. objNewInstance.Put_(CONST_WBEM_FLAG)
  1976. If Err.Number Then
  1977. Err.Clear
  1978. WScript.Echo(L_CannotCreate_ErrorMessage)
  1979. WScript.Quit(EXIT_INVALID_INPUT)
  1980. End If
  1981. component.VBPrintf CreateSuccessMessage, _
  1982. Array(CInt(intIntSize),CInt(intMaxSize),UCase(arrVolume(i)))
  1983. blnSuccessMsg = TRUE
  1984. End If
  1985. End If
  1986. End If
  1987. Else
  1988. ' get the upper bound allowed for maximum size
  1989. intMaxSizeUB = getMaxSizeUB(objService)
  1990. component.VBPrintf InitialSizeRangeErrorMessage, Array(intMaxSizeUB)
  1991. End If
  1992. End If
  1993. End If
  1994. End If
  1995. i = i + 1
  1996. Loop
  1997. If blnSuccessMsg = TRUE then
  1998. WScript.Echo L_RestartComputer_Message
  1999. End If
  2000. End Sub
  2001. '******************************************************************************
  2002. '* Sub: ProcessDelete
  2003. '*
  2004. '* Purpose: Deletes existing page files on the specified volumes
  2005. '*
  2006. '* Input:
  2007. '* [in] strMachine machine to configure page files on
  2008. '* [in] strUserName user name to connect to the machine
  2009. '* [in] strPassword password for the user
  2010. '* [in] objVols the object containing volume names
  2011. '*
  2012. '* Output: Displays error message and quits if connection fails
  2013. '*
  2014. '******************************************************************************
  2015. Private Sub ProcessDelete ( ByVal strMachine, _
  2016. ByVal strUserName, _
  2017. ByVal strPassword, _
  2018. ByVal objVols )
  2019. ON ERROR RESUME NEXT
  2020. Err.Clear
  2021. Dim arrVolume ' to store all the volumes specified
  2022. Dim intVolumes ' to store the no.of volumes specified
  2023. Dim objService ' service object
  2024. Dim objInstance ' instance object
  2025. Dim blnSuccessMsg ' flag to check if a SUCCESS message is generated
  2026. Dim strQueryDisk ' to store the query for disk
  2027. Dim objEnumforDisk ' collection object for query results
  2028. Dim intMemSize ' to store physical memory size
  2029. Dim intCrashDump ' to store the current crash dump setting value
  2030. Dim strQueryComp ' to store the query for computersystem
  2031. Dim objEnum ' collection object for query results
  2032. Dim objInst ' instance object
  2033. Dim strHostName ' to store the host name
  2034. Dim i ' Loop variable
  2035. If NOT component.wmiConnect(CONST_NAMESPACE_CIMV2 , _
  2036. strUserName , _
  2037. strPassword , _
  2038. strMachine , _
  2039. blnLocalConnection , _
  2040. objService ) Then
  2041. WScript.Echo(L_HintCheckConnection_Message)
  2042. WScript.Quit(EXIT_METHOD_FAIL)
  2043. End If
  2044. i = 0
  2045. blnSuccessMsg = FALSE
  2046. intVolumes = objVols.Count
  2047. arrVolume = objVols.Keys
  2048. ' Get the host Name - used to get Crash Dump Settings
  2049. strQueryComp = "Select * From " & CLASS_COMPUTER_SYSTEM
  2050. Set objEnum = objService.ExecQuery(strQueryComp, "WQL", 0, null)
  2051. ' check for any errors
  2052. If Err.Number Then
  2053. Err.Clear
  2054. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  2055. WScript.Quit(EXIT_QUERY_FAIL)
  2056. End If
  2057. For each objInst in objEnum
  2058. If NOT ISEmpty(objInst.Name) Then
  2059. strHostName = objInst.Name
  2060. Else
  2061. WSCript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  2062. WScript.Quit(EXIT_QUERY_FAIL)
  2063. End If
  2064. Next
  2065. Do While( i < intVolumes )
  2066. strQueryDisk = "Select * From " & CLASS_LOGICAL_DISK & _
  2067. " where DriveType = " & DRIVE_TYPE & " and DeviceID = '" & arrVolume(i) & "'"
  2068. Set objEnumforDisk = objService.ExecQuery(strQueryDisk, "WQL", 0, null)
  2069. If objEnumforDisk.Count > 0 Then
  2070. Set objInstance = objService.Get(CLASS_PAGE_FILE_SETTING & "='" & _
  2071. arrVolume(i) & PAGEFILE_DOT_SYS & "'")
  2072. If Err.Number Then
  2073. Err.Clear
  2074. component.VBPrintf L_PageFileDoesNotExist_ErrorMessage, _
  2075. Array(UCase(arrVolume(i)))
  2076. Else
  2077. ' check for system managed pagefiles
  2078. If (objInstance.InitialSize = 0 AND objInstance.MaximumSize = 0) Then
  2079. component.VBPrintf L_SystemManagedSize_ErrorMessage, _
  2080. Array(UCase(arrVolume(i)))
  2081. Else
  2082. ' get the crash dump setting value
  2083. intCrashDump = GetCrashDumpSetting(strUserName,strPassword,strMachine)
  2084. ' get the Physical Memory Size
  2085. intMemSize = GetPhysicalMemorySize(strHostName,objService)
  2086. ' If the user has selected "yes" for the warning message
  2087. ' pass initsize as 0 because initsize = maxsize = 0 (assumed) after deletion
  2088. If isCrashDumpValueSet(intCrashDump,0,intMemSize,arrVolume(i)) Then
  2089. ' Delete the instance
  2090. objInstance.Delete_
  2091. ' check for any errors
  2092. If Err.Number Then
  2093. Err.Clear
  2094. WScript.Echo(L_InvalidInput_ErrorMessage)
  2095. WScript.Quit(EXIT_INVALID_INPUT)
  2096. End If
  2097. component.VBPrintf L_DeleteSuccess_Message, _
  2098. Array(UCase(arrVolume(i)))
  2099. blnSuccessMsg = TRUE
  2100. End If
  2101. End If
  2102. End If
  2103. Else
  2104. ' the drive does not exist
  2105. component.VBPrintf L_InvalidVolumeName_ErrorMessage, _
  2106. Array(UCase(arrVolume(i)))
  2107. ' remove the drive name from the valid drives list
  2108. objVols.Remove arrVolume(i)
  2109. ' decrement the loop count
  2110. i = i - 1
  2111. ' check for the no.of valid drive names from the specified list.
  2112. If Cint(objVols.Count) = 0 Then
  2113. WScript.Quit(EXIT_INVALID_INPUT)
  2114. Else
  2115. intVolumes = objVols.Count
  2116. arrVolume = objVols.keys
  2117. End If
  2118. End If
  2119. i = i + 1
  2120. Loop
  2121. ' The instances of the following classes are also deleted along with the Win32_PageFile instances
  2122. ' Win32_PageFileUsage - instances are deleted only after reboot
  2123. ' Win32_PageFileSetting - instances are deleted automatically along with Win32_PageFile instances
  2124. If blnSuccessMsg = TRUE then
  2125. WScript.Echo L_RestartComputer_Message
  2126. End If
  2127. End sub
  2128. '******************************************************************************
  2129. '* Sub: ProcessQuery
  2130. '*
  2131. '* Purpose: Displays the Page File Details in the specified format
  2132. '*
  2133. '* Input:
  2134. '* [in] strMachine machine to configure page files on
  2135. '* [in] strUserName user name to connect to the machine
  2136. '* [in] strPassword password for the user
  2137. '* [in] strFormat the query display format
  2138. '*
  2139. '* Output: Displays error message and quits if connection fails
  2140. '* Calls component.showResults() to display the page file
  2141. '* details
  2142. '*
  2143. '******************************************************************************
  2144. Private Sub ProcessQuery( ByVal strMachine, _
  2145. ByVal strUserName, _
  2146. ByVal strPassword, _
  2147. ByVal strFormat )
  2148. ON ERROR RESUME NEXT
  2149. Err.Clear
  2150. Dim objEnumerator ' to store the results of the query is executed
  2151. Dim objInstance ' to refer to the instances of the objEnumerator
  2152. Dim strQuery ' to store the query obtained for given conditions
  2153. Dim intTotSize ' to store the total size on all drives
  2154. Dim intRecommendedSize ' to store the recommended size for all drives
  2155. Dim arrResultsDrives ' to store the columns of page file info.
  2156. Dim arrHeaderDrives ' to store the array header values
  2157. Dim arrMaxLengthDrives ' to store the maximum length for each column
  2158. Dim arrFinalResultsDrives ' used to send the arrResults to ShowResults()
  2159. Dim intColumnCountDrives ' number of columns to be displayed in the output
  2160. Dim blnPrintHeaderDrives ' variable which decides whether header is to be displayed or not
  2161. Dim arrResultsSummary ' to store the columns of page file info.
  2162. Dim arrHeaderSummary ' to store the array header values
  2163. Dim arrMaxLengthSummary ' to store the maximum length for each column
  2164. Dim arrFinalResultsSummary ' used to send the arrResults to ShowResults()
  2165. Dim intColumnCountSummary ' number of columns to be displayed in the output
  2166. Dim blnPrintHeaderSummary ' variable which decides whether header is to be displayed or not
  2167. Dim objDiskDriveInstance ' Instance for drive name
  2168. Dim objMemSizeInstance ' Instance for memory size
  2169. Dim arrblnNoDisplayDrives ' boolean variable for -noheader option
  2170. Dim arrblnNoDisplaySummary ' boolean variable for -noheader option
  2171. Dim objService ' service object
  2172. Dim strDriveName ' to store the drive name
  2173. Dim objUsageInstance ' Instance for PageFileUsage
  2174. ' Initializing the blnPrintHeaders to true. Header should be printed by default
  2175. blnPrintHeaderDrives = TRUE
  2176. blnPrintHeaderSummary = TRUE
  2177. intTotSize = 0
  2178. If NOT component.wmiConnect(CONST_NAMESPACE_CIMV2 , _
  2179. strUserName , _
  2180. strPassword , _
  2181. strMachine , _
  2182. blnLocalConnection , _
  2183. objService ) Then
  2184. WScript.Echo(L_HintCheckConnection_Message)
  2185. WScript.Quit(EXIT_METHOD_FAIL)
  2186. End If
  2187. arrHeaderDrives = Array(L_ColHeaderHostname_Text , L_ColHeaderDrive_Text, _
  2188. L_ColHeaderVolumeLabel_Text, L_ColHeaderFileName_Text, _
  2189. L_ColHeaderInitialSize_Text, L_ColHeaderMaximumSize_Text, _
  2190. L_ColHeaderCurrentSize_Text, L_ColHeaderFreeSpace_Text)
  2191. arrHeaderSummary = Array(L_ColHeaderHostname_Text, L_ColHeaderTotalMinimumSize_Text, _
  2192. L_ColHeaderTotalRecommendedSize_Text, L_ColHeaderTotalSize_Text)
  2193. ' Data Lengths = (15,13,13,19,20,20,20,22)
  2194. arrMaxLengthDrives = Array(CONST_HOSTNAME_LENGTH, CONST_DRIVENAME_LENGTH, CONST_VOLLABEL_LENGTH, _
  2195. CONST_PAGEFILENAME_LENGTH, CONST_INTSIZE_LENGTH, CONST_MAXSIZE_LENGTH, _
  2196. CONST_CURRENTSIZE_LENGTH, CONST_FREESPACE_LENGTH)
  2197. ' Data Lengths = (15,33,37,40)
  2198. arrMaxLengthSummary = Array(CONST_HOSTNAME_LENGTH,CONST_TOTALMINSIZE_LENGTH,_
  2199. CONST_TOTALRECSIZE_LENGTH,CONST_TOTALSIZE_LENGTH)
  2200. arrblnNoDisplayDrives = Array(0,0,0,0,0,0,0,0)
  2201. arrblnNoDisplaySummary = Array(0,0,0,0)
  2202. ' first initialize the array with N/A
  2203. arrResultsDrives = Array(L_Na_Text,L_Na_Text,L_Na_Text,L_Na_Text,L_Na_Text,L_Na_Text,_
  2204. L_Na_Text,L_Na_Text)
  2205. arrResultsSummary = Array(L_Na_Text,L_Na_Text,L_Na_Text,L_Na_Text)
  2206. ' build the query
  2207. strQuery = "SELECT * FROM " & CLASS_PAGE_FILE_SETTING
  2208. ' execute the query
  2209. Set objEnumerator = objService.ExecQuery(strQuery, "WQL", 0, null)
  2210. ' check for any errors
  2211. If Err.Number Then
  2212. Err.Clear
  2213. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  2214. WScript.Quit(EXIT_QUERY_FAIL)
  2215. End If
  2216. ' If no.of pagefile instances are 0 (zero)
  2217. If (objEnumerator.Count = 0) Then
  2218. WScript.Echo(L_NoPageFiles_Message)
  2219. WScript.Quit(EXIT_UNEXPECTED)
  2220. End If
  2221. ReDim arrFinalResultsDrives(0)
  2222. ReDim arrFinalResultsSummary(0)
  2223. WScript.Echo("") ' Blank Line
  2224. ' Loop through all the instances for the first report
  2225. For each objInstance in objEnumerator
  2226. If NOT IsEmpty(objInstance.Name) Then
  2227. strDriveName = Mid(objInstance.Name,1,2)
  2228. End If
  2229. ' check if it is a valid physical drive
  2230. If IsValidPhysicalDrive(objService,strDriveName) Then
  2231. If IsEmpty(objInstance.Name) Then
  2232. arrResultsDrives(1) = L_Na_Text
  2233. Else
  2234. strDriveName = Mid(objInstance.Name,1,2)
  2235. arrResultsDrives(1) = UCase(strDriveName)
  2236. End If
  2237. ' to get the data from Win32_PageFileUsage
  2238. Set objUsageInstance = objService.Get(CLASS_PAGE_FILE_USAGE & "='" & objInstance.Name & "'")
  2239. ' to get the current size
  2240. If Len(objUsageInstance.AllocatedBaseSize) = 0 Then
  2241. arrResultsDrives(6) = L_Na_Text
  2242. Else
  2243. arrResultsDrives(6) = objUsageInstance.AllocatedBaseSize & MEGA_BYTES
  2244. intTotSize = intTotSize + objUsageInstance.AllocatedBaseSize
  2245. End If
  2246. ' to get the data from Win32_LogicalDisk
  2247. Set objDiskDriveInstance = objService.Get(CLASS_LOGICAL_DISK & "='" & strDriveName & "'")
  2248. If Len(objDiskDriveInstance.VolumeName) = 0 Then
  2249. arrResultsDrives(2) = L_Na_Text
  2250. Else
  2251. arrResultsDrives(2) = objDiskDriveInstance.VolumeName
  2252. End If
  2253. If Len(objDiskDriveInstance.SystemName) = 0 Then
  2254. arrResultsDrives(0) = L_Na_Text
  2255. Else
  2256. arrResultsDrives(0) = objDiskDriveInstance.SystemName
  2257. arrResultsSummary(0) = objDiskDriveInstance.SystemName
  2258. End If
  2259. If (objDiskDriveInstance.FreeSpace) Then
  2260. arrResultsDrives(7) = Int(objDiskDriveInstance.FreeSpace/CONVERSION_FACTOR) + Int(objUsageInstance.AllocatedBaseSize) &_
  2261. MEGA_BYTES
  2262. Else
  2263. arrResultsDrives(7) = L_Na_Text
  2264. End If
  2265. If IsEmpty(objInstance.Name) Then
  2266. arrResultsDrives(3) = L_Na_Text
  2267. Else
  2268. arrResultsDrives(3) = objInstance.Name
  2269. End If
  2270. If objInstance.InitialSize Then
  2271. arrResultsDrives(4) = objInstance.InitialSize & MEGA_BYTES
  2272. Else
  2273. arrResultsDrives(4) = L_Na_Text
  2274. End If
  2275. If objInstance.MaximumSize Then
  2276. arrResultsDrives(5) = objInstance.MaximumSize & MEGA_BYTES
  2277. Else
  2278. arrResultsDrives(5) = L_Na_Text
  2279. End If
  2280. arrFinalResultsDrives(0) = arrResultsDrives
  2281. Call component.showResults(arrHeaderDrives, arrFinalResultsDrives, arrMaxLengthDrives, _
  2282. strFormat, blnPrintHeaderDrives, arrblnNoDisplayDrives)
  2283. blnPrintHeaderDrives = FALSE
  2284. End If
  2285. Next
  2286. WScript.Echo("")
  2287. ' Display the summary report
  2288. arrResultsSummary(1) = INITIAL_SIZE_LB & MEGA_BYTES
  2289. Set objMemSizeInstance = objService.Get(CLASS_COMPUTER_SYSTEM & "='" & arrResultsDrives(0) & "'")
  2290. If objMemSizeInstance.TotalPhysicalMemory Then
  2291. intRecommendedSize = Int(Int(objMemSizeInstance.TotalPhysicalMemory/CONVERSION_FACTOR)* SIZE_FACTOR)
  2292. arrResultsSummary(2) = intRecommendedSize & MEGA_BYTES
  2293. Else
  2294. arrResultsSummary(2) = L_Na_Text
  2295. End If
  2296. arrResultsSummary(3) = intTotSize & MEGA_BYTES
  2297. arrFinalResultsSummary(0) = arrResultsSummary
  2298. Call component.showResults(arrHeaderSummary, arrFinalResultsSummary, arrMaxLengthSummary, strFormat, _
  2299. blnPrintHeaderSummary,arrblnNoDisplaySummary)
  2300. blnPrintHeaderSummary = FALSE
  2301. End Sub
  2302. '******************************************************************************
  2303. '* Function: IsValidPhysicalDrive
  2304. '*
  2305. '* Purpose: To check if the specified drive is a valid physical drive.
  2306. '* This check is done only for Win2K builds and NOT for Whistler Builds.
  2307. '*
  2308. '* Input:
  2309. '* [in] objServiceParam service object to maintain wmi connection.
  2310. '* [in] strDriveName drive name whose validity has to be checked.
  2311. '*
  2312. '* Output: Returns TRUE or FALSE
  2313. '* TRUE - when the drive is a valid physical drive.
  2314. '* FALSE - when the drive is not a valid physical drive.
  2315. '*
  2316. '******************************************************************************
  2317. Private Function IsValidPhysicalDrive ( ByVal objServiceParam, _
  2318. ByVal strDriveName )
  2319. ON ERROR RESUME NEXT
  2320. Err.Clear
  2321. CONST WIN2K_MAJOR_VERSION = 5000
  2322. CONST WINXP_MAJOR_VERSION = 5001
  2323. Dim strQuery ' to store the query to be executed
  2324. Dim objEnum ' collection object
  2325. Dim objInstance ' instance object
  2326. Dim strValidDrives ' to store all valid physical drives
  2327. Dim strVersion ' to store the OS version
  2328. Dim arrVersionElements ' to store the OS version elements
  2329. Dim CurrentMajorVersion ' the major version number
  2330. strValidDrives = ""
  2331. ' by default set it to true
  2332. IsValidPhysicalDrive = TRUE
  2333. strquery = "Select * From " & CLASS_OPERATING_SYSTEM
  2334. set objEnum = objServiceParam.ExecQuery(strQuery,"WQL",48,null)
  2335. For each objInstance in objEnum
  2336. strVersion= objInstance.Version
  2337. Next
  2338. ' OS Version : 5.1.xxxx(Whistler), 5.0.xxxx(Win2K)
  2339. arrVersionElements = split(strVersion,".")
  2340. ' converting to major version
  2341. CurrentMajorVersion = arrVersionElements(0) * 1000 + arrVersionElements(1)
  2342. ' Determine the OS Type
  2343. ' If the OS is Whistler, then NO NEED to validate.
  2344. ' If the OS is Win2K, then validate the drive name.
  2345. If CInt(CurrentMajorVersion) < CInt(WINXP_MAJOR_VERSION) Then
  2346. strQuery = "Select * From " & CLASS_PERFDISK_PHYSICAL_DISK
  2347. Set objEnum = objServiceParam.ExecQuery(strQuery, "WQL", 0, null)
  2348. For each objInstance in objEnum
  2349. ' get all the instance except the last one
  2350. If (objInstance.Name <> "_Total") Then
  2351. strValidDrives = strValidDrives & " " & objInstance.Name
  2352. End If
  2353. Next
  2354. ' check if the specified drive is present in the list of valid physical drives
  2355. If Instr(strValidDrives, UCase(strDriveName)) = 0 Then
  2356. IsValidPhysicalDrive = FALSE
  2357. End If
  2358. End If
  2359. End Function
  2360. '******************************************************************************
  2361. '* Function: getFreeSpaceOnDisk
  2362. '*
  2363. '* Purpose: To get the Free Space for the Specified Disk
  2364. '*
  2365. '* Input:
  2366. '* [in] strDriveName drive name whose free space is needed
  2367. '* [in] objServiceParam service object to maintain wmi connection
  2368. '*
  2369. '* Output: Returns the free space (in MB) on the specified disk.
  2370. '*
  2371. '******************************************************************************
  2372. Private Function getFreeSpaceOnDisk(ByVal strDriveName, ByVal objServiceParam)
  2373. ON ERROR RESUME NEXT
  2374. Err.Clear
  2375. Dim objValidDiskInst
  2376. Set objValidDiskInst = objServiceParam.Get(CLASS_LOGICAL_DISK & "='" & strDriveName & "'")
  2377. If Err.Number Then
  2378. Err.Clear
  2379. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  2380. WScript.Quit(EXIT_QUERY_FAIL)
  2381. End If
  2382. getFreeSpaceOnDisk = Int(objValidDiskInst.FreeSpace/CONVERSION_FACTOR)
  2383. End Function
  2384. '******************************************************************************
  2385. '* Function: getCurrentPageFileSize
  2386. '*
  2387. '* Purpose: To get the current pagefile size on the specified drive
  2388. '*
  2389. '* Input:
  2390. '* [in] objService wbem service object
  2391. '* [in] objInstance instance of win32_pagefilesetting
  2392. '*
  2393. '* Output: current pagefile size
  2394. '*
  2395. '******************************************************************************
  2396. Private Function getCurrentPageFileSize(ByVal objService, ByVal objInstance)
  2397. ON ERROR RESUME NEXT
  2398. Err.Clear
  2399. Dim objUsageInstance
  2400. ' get the data from Win32_PageFileUsage
  2401. Set objUsageInstance = objService.Get(CLASS_PAGE_FILE_USAGE & "='" & objInstance.Name & "'")
  2402. ' return the current size ( allocated base size )
  2403. getCurrentPageFileSize = objUsageInstance.AllocatedBaseSize
  2404. End Function
  2405. '******************************************************************************
  2406. '* Function: GetDiskSize
  2407. '*
  2408. '* Purpose: To get the disk size for the specified drive
  2409. '*
  2410. '* Input:
  2411. '* [in] strDriveName drive name whose free space is needed
  2412. '* [in] objServiceParam service object to maintain wmi connection
  2413. '*
  2414. '* Output: Returns the total disk size in MB.
  2415. '*
  2416. '******************************************************************************
  2417. Private Function GetDiskSize(ByVal strDriveName, ByVal objServiceParam)
  2418. ON ERROR RESUME NEXT
  2419. Err.Clear
  2420. Dim objValidDiskInst ' object to store valid disk name
  2421. Set objValidDiskInst = objServiceParam.Get(CLASS_LOGICAL_DISK & "='" & strDriveName & "'")
  2422. If Err.Number Then
  2423. Err.Clear
  2424. WScript.Echo(L_UnableToRetrieveInfo_ErrorMessage)
  2425. WScript.Quit(EXIT_QUERY_FAIL)
  2426. End If
  2427. GetDiskSize = Int(objValidDiskInst.Size / CONVERSION_FACTOR)
  2428. End Function
  2429. '******************************************************************************
  2430. '* Function: GetPhysicalMemorySize
  2431. '*
  2432. '* Purpose: To get the physical memory size.
  2433. '*
  2434. '* Input:
  2435. '* [in] strHostName host name to connect to
  2436. '* [in] objServiceParam service object to maintain wmi connection
  2437. '*
  2438. '* Output: Returns the physical memory size in MB.
  2439. '*
  2440. '******************************************************************************
  2441. Private Function GetPhysicalMemorySize( ByVal strHostName, ByVal objServiceParam )
  2442. ON ERROR RESUME NEXT
  2443. Err.Clear
  2444. Dim objMemSizeInstance ' to store memory size
  2445. Dim intReturnValue ' to store return value
  2446. Set objMemSizeInstance = objServiceParam.Get(CLASS_COMPUTER_SYSTEM & "='" & strHostName & "'")
  2447. If Err.Number Then
  2448. Err.Clear
  2449. WScript.Echo L_UnableToRetrieveInfo_ErrorMessage
  2450. WScript.Quit EXIT_QUERY_FAIL
  2451. End If
  2452. If objMemSizeInstance.TotalPhysicalMemory Then
  2453. intReturnValue = Int(objMemSizeInstance.TotalPhysicalMemory/CONVERSION_FACTOR)
  2454. GetPhysicalMemorySize = intReturnValue
  2455. End If
  2456. End Function
  2457. '******************************************************************************
  2458. '* Function: getMaxSizeUB
  2459. '*
  2460. '* Purpose: To get the allowed upper bound for maximum size
  2461. '*
  2462. '* Input:
  2463. '* [in] objServiceParam service object to maintain wmi connection
  2464. '*
  2465. '* Output: Returns the upper bound for maximum size
  2466. '*
  2467. '******************************************************************************
  2468. Private Function getMaxSizeUB(objServiceParam)
  2469. ON ERROR RESUME NEXT
  2470. Err.Clear
  2471. CONST PROCESSOR_X86_BASED = "X86"
  2472. CONST PROCESSOR_IA64_BASED = "IA64"
  2473. Dim objInstance ' object instance
  2474. Dim intReturnValue ' to store return value
  2475. Dim strProcessorType ' to store the processor type
  2476. Dim strQuery ' to store the query
  2477. Dim objEnum ' collection of objects
  2478. getMaxSizeUB = 0
  2479. strQuery = "Select * From " & CLASS_COMPUTER_SYSTEM
  2480. Set objEnum = objServiceParam.ExecQuery(strQuery,"WQL",48,null)
  2481. If Err.Number Then
  2482. Err.Clear
  2483. WScript.Echo L_UnableToRetrieveInfo_ErrorMessage
  2484. WScript.Quit EXIT_QUERY_FAIL
  2485. End If
  2486. ' The following code will handle only single processor environment
  2487. For each objInstance in objEnum
  2488. strProcessorType = objInstance.SystemType
  2489. Next
  2490. ' check if its a 32-bit processor
  2491. If InStr( UCase(strProcessorType),PROCESSOR_X86_BASED ) > 0 Then
  2492. getMaxSizeUB = 4096
  2493. End If
  2494. ' check if its a 64-bit processor
  2495. If Instr( UCase(strProcessorType),PROCESSOR_IA64_BASED ) > 0 Then
  2496. getMaxSizeUB = 33554432
  2497. End If
  2498. End Function
  2499. '******************************************************************************
  2500. '* Function: GetCrashDumpSetting
  2501. '*
  2502. '* Purpose: To get the Crash Dump Settings for the machine specified
  2503. '*
  2504. '* Input:
  2505. '* [in] strUserNameParam user name to connect to the machine
  2506. '* [in] strPasswordParam password for the user
  2507. '* [in] strMachineParam machine to get crash dump settings for
  2508. '*
  2509. '* Output: Returns the current crash dump setting value [ 0,1,2,3 ]
  2510. '* 0 - None
  2511. '* 1 - Complete Memory Dump
  2512. '* 2 - Kernel Memory Dump
  2513. '* 3 - Small Memory Dump
  2514. '*
  2515. '******************************************************************************
  2516. Private Function GetCrashDumpSetting( ByVal strUserNameParam, _
  2517. ByVal strPasswordParam, _
  2518. ByVal strMachineParam )
  2519. ON ERROR RESUME NEXT
  2520. Err.Clear
  2521. CONST CONST_NAMESPACE_DEFAULT = "root\default" ' name space to connect to
  2522. CONST CONST_HKEY_LOCAL_MACHINE = 2147483650 ' registry value for HKEY_LOCAL_MACHINE
  2523. CONST CONST_KEY_VALUE_NAME = "CrashDumpEnabled" ' value name to be retrieved
  2524. CONST CONST_STD_REGISTRY_PROVIDER = "StdRegProv" ' standard registry provider
  2525. ' the Sub Key Name
  2526. CONST CONST_CRASH_DUMP_REGKEY = "SYSTEM\CurrentControlSet\Control\CrashControl"
  2527. Dim objInstance ' to store the object instance
  2528. Dim objService ' service object
  2529. Dim intCrashDumpValue ' to store the crash dump setting value
  2530. Dim intReturnVal ' to store return value
  2531. ' connect to the name space
  2532. If NOT component.wmiConnect(CONST_NAMESPACE_DEFAULT , _
  2533. strUserNameParam , _
  2534. strPasswordParam , _
  2535. strMachineParam , _
  2536. blnLocalConnection , _
  2537. objService ) Then
  2538. WScript.Echo(L_HintCheckConnection_Message)
  2539. WScript.Quit(EXIT_METHOD_FAIL)
  2540. End If
  2541. ' get the instance of the Standard Registry Provider
  2542. Set objInstance = objService.Get(CONST_STD_REGISTRY_PROVIDER)
  2543. ' get the key value for from the registry
  2544. intReturnVal = objInstance.GetDWORDValue( CONST_HKEY_LOCAL_MACHINE, _
  2545. CONST_CRASH_DUMP_REGKEY, _
  2546. CONST_KEY_VALUE_NAME, _
  2547. intCrashDumpValue )
  2548. ' check if any error has occured
  2549. If Err.Number <> 0 Then
  2550. Err.Clear
  2551. WScript.Echo(L_FailCreateObject_ErrorMessage)
  2552. WScript.Quit(EXIT_INVALID_PARAM)
  2553. End If
  2554. ' check for the return value after registry is accessed.
  2555. If intReturnVal = 0 Then
  2556. GetCrashDumpSetting = CInt(intCrashDumpValue)
  2557. Else
  2558. WScript.Echo(L_FailCreateObject_ErrorMessage)
  2559. WScript.Quit(EXIT_INVALID_PARAM)
  2560. End If
  2561. End Function
  2562. ' Function used to get the reply in y/n from the user
  2563. '******************************************************************************
  2564. '* Function: getReply
  2565. '*
  2566. '* Purpose: To get reply from the user
  2567. '*
  2568. '* Input: None
  2569. '*
  2570. '* Output: Prompts for a warning message and accepts the user's choice [y/n]
  2571. '*
  2572. '******************************************************************************
  2573. Private Function getReply()
  2574. ON ERROR RESUME NEXT
  2575. Err.Clear
  2576. Dim objStdIn ' to store value from standard input
  2577. Dim strReply ' to store the user reply
  2578. WScript.Echo(L_PromptForContinueAnyWay_Message)
  2579. Set objStdIn = WScript.StdIn
  2580. If Err.Number Then
  2581. Err.Clear
  2582. WScript.Echo(L_FailCreateObject_ErrorMessage)
  2583. WScript.Quit(EXIT_INVALID_PARAM)
  2584. End If
  2585. strReply = objStdIn.ReadLine()
  2586. getReply = Trim(strReply)
  2587. End Function
  2588. '******************************************************************************
  2589. '* Function: isCrashDumpValueSet
  2590. '*
  2591. '* Purpose: To check if the crash dump value is set
  2592. '*
  2593. '* Input:
  2594. '* [in] intCrashDumpParam crash dump setting value
  2595. '* [in] intIntSizeParam initial size of the pagefile
  2596. '* [in] intMemSizeParam physical memory size
  2597. '* [in] strVolume drive/volume name
  2598. '*
  2599. '* Output: Returns TRUE or FALSE
  2600. '*
  2601. '******************************************************************************
  2602. Private Function isCrashDumpValueSet( ByVal intCrashDumpParam,_
  2603. ByVal intIntSizeParam, _
  2604. ByVal intMemSizeParam, _
  2605. ByVal strVolume )
  2606. ON ERROR RESUME NEXT
  2607. Err.Clear
  2608. ' Constants for Crash Dump Settings
  2609. CONST NO_MEMORY_DUMP = 0
  2610. CONST COMPLETE_MEMORY_DUMP = 1
  2611. CONST KERNEL_MEMORY_DUMP = 2
  2612. CONST SMALL_MEMORY_DUMP = 3
  2613. Dim strReply ' to store user reply
  2614. Dim intSizeValue ' to store the size value used for comparison
  2615. ' default value is NO [n]
  2616. strReply = L_UserReplyNo_Text
  2617. Select Case CInt(intCrashDumpParam)
  2618. Case COMPLETE_MEMORY_DUMP
  2619. If CInt(intIntSizeParam) < CInt(intMemSizeParam) Then
  2620. component.VBPrintf CrashDumpSettingWarningMessage, Array(UCase(strVolume),CInt(intMemSizeParam) & MEGA_BYTES)
  2621. ' Ask for choice until a yes[y] or no[n] is given
  2622. Do
  2623. strReply = getReply()
  2624. If Trim(LCase(strReply)) = L_UserReplyYes_Text Then
  2625. isCrashDumpValueSet = TRUE
  2626. ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then
  2627. isCrashDumpValueSet = FALSE
  2628. Else
  2629. WScript.Echo(L_InvalidUserReply_ErrorMessage)
  2630. End If
  2631. Loop Until (Trim(LCase(strReply)) = L_UserReplyYes_Text OR Trim(LCase(strReply)) = L_UserReplyNo_Text)
  2632. Else
  2633. isCrashDumpValueSet = TRUE
  2634. End If
  2635. Case KERNEL_MEMORY_DUMP
  2636. ' check if RAM size is less than or equal to 128 MB
  2637. If CInt(intMemSizeParam) <= 128 Then
  2638. ' assign size value to be checked to 50 MB
  2639. intSizeValue = 50
  2640. Else
  2641. ' check if RAM size is less than or equal to 4 GB
  2642. If CInt(intMemSizeParam) <= 4096 Then
  2643. ' assign size value to be checked to 200 MB
  2644. intSizeValue = 200
  2645. Else
  2646. ' check if RAM size is less than or equal to 8 GB
  2647. If CInt(intMemSizeParam) <= 8192 Then
  2648. ' assign size value to be checked to 400 MB
  2649. intSizeValue = 400
  2650. Else
  2651. ' assign size value to be checked to 800 MB
  2652. intSizeValue = 800
  2653. End If
  2654. End If
  2655. End If
  2656. If CInt(intIntSizeParam) < CInt(intSizeValue) Then
  2657. component.VBPrintf CrashDumpSettingWarningMessage, Array(UCase(strVolume),intSizeValue & MEGA_BYTES)
  2658. ' Ask for choice until a yes[y] or no[n] is given
  2659. Do
  2660. strReply = getReply()
  2661. If Trim(LCase(strReply)) = L_UserReplyYes_Text Then
  2662. isCrashDumpValueSet = TRUE
  2663. ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then
  2664. isCrashDumpValueSet = FALSE
  2665. Else
  2666. WScript.Echo(L_InvalidUserReply_ErrorMessage)
  2667. End If
  2668. Loop Until (Trim(LCase(strReply)) = L_UserReplyYes_Text OR Trim(LCase(strReply)) = L_UserReplyNo_Text)
  2669. Else
  2670. isCrashDumpValueSet = TRUE
  2671. End If
  2672. Case SMALL_MEMORY_DUMP
  2673. ' initial size should not be less than 64 KB ( less than or equal to 0 MB )
  2674. If CInt(intIntSizeParam) <= 0 Then
  2675. component.VBPrintf CrashDumpSettingWarningMessage, Array(UCase(strVolume),"64 KB")
  2676. ' Ask for choice until a yes[y] or no[n] is given
  2677. Do
  2678. strReply = getReply()
  2679. If Trim(LCase(strReply)) = L_UserReplyYes_Text Then
  2680. isCrashDumpValueSet = TRUE
  2681. ElseIf Trim(LCase(strReply)) = L_UserReplyNo_Text Then
  2682. isCrashDumpValueSet = FALSE
  2683. Else
  2684. WScript.Echo(L_InvalidUserReply_ErrorMessage)
  2685. End If
  2686. Loop Until (Trim(LCase(strReply)) = L_UserReplyYes_Text OR Trim(LCase(strReply)) = L_UserReplyNo_Text)
  2687. Else
  2688. isCrashDumpValueSet = TRUE
  2689. End If
  2690. Case NO_MEMORY_DUMP
  2691. ' Crash Dump values 0 has no problem
  2692. isCrashDumpValueSet = TRUE
  2693. End Select
  2694. End Function
  2695. '******************************************************************************
  2696. '* Sub: typeMessage
  2697. '*
  2698. '* Purpose: To print the type usage messages relevent to the main option
  2699. '* selected.
  2700. '*
  2701. '* Input: The main option selected.
  2702. '*
  2703. '* Output: Prints "type..usage" messages for the main option selected.
  2704. '*
  2705. '******************************************************************************
  2706. Sub typeMessage(ByVal intMainOption)
  2707. ON ERROR RESUME NEXT
  2708. Err.Clear
  2709. Select Case CInt(intMainOption)
  2710. Case CONST_CHANGE_OPTION
  2711. component.VBPrintf L_TypeChangeUsage_Message,Array(UCase(WScript.ScriptName))
  2712. Case CONST_CREATE_OPTION
  2713. component.VBPrintf L_TypeCreateUsage_Message,Array(UCase(WScript.ScriptName))
  2714. Case CONST_DELETE_OPTION
  2715. component.VBPrintf L_TypeDeleteUsage_Message,Array(UCase(WScript.ScriptName))
  2716. Case CONST_QUERY_OPTION
  2717. component.VBPrintf L_TypeQueryUsage_Message,Array(UCase(WScript.ScriptName))
  2718. Case Else
  2719. component.VBPrintf L_TypeUsage_Message,Array(UCase(WScript.ScriptName))
  2720. End Select
  2721. End Sub
  2722. '******************************************************************************
  2723. '* Sub: ShowUsage
  2724. '*
  2725. '* Purpose: Shows the correct usage to the user.
  2726. '*
  2727. '* Input: None
  2728. '*
  2729. '* Output: Help messages are displayed on screen.
  2730. '*
  2731. '******************************************************************************
  2732. Sub ShowUsage()
  2733. WScript.Echo vbCr ' Line 1
  2734. WScript.Echo( L_ShowUsageLine02_Text ) ' Line 2
  2735. WScript.Echo vbCr ' Line 3
  2736. WScript.Echo( L_UsageDescription_Text ) ' Line 4
  2737. WScript.Echo( L_ShowUsageLine05_Text ) ' Line 5
  2738. WScript.Echo( L_ShowUsageLine06_Text ) ' Line 6
  2739. WScript.Echo vbCr ' Line 7
  2740. WScript.Echo( L_ShowUsageLine08_Text ) ' Line 8
  2741. WScript.Echo( L_ShowUsageLine09_Text ) ' Line 9
  2742. WScript.Echo( L_ShowUsageLine10_Text ) ' Line 10
  2743. WScript.Echo vbCr ' Line 11
  2744. WScript.Echo( L_ShowUsageLine12_Text ) ' Line 12
  2745. WScript.Echo vbCr ' Line 13
  2746. WScript.Echo( L_ShowUsageLine14_Text ) ' Line 14
  2747. WScript.Echo vbCr ' Line 15
  2748. WScript.Echo( L_ShowUsageLine16_Text ) ' Line 16
  2749. WScript.Echo( L_ShowUsageLine17_Text ) ' Line 17
  2750. WScript.Echo vbCr ' Line 18
  2751. WScript.Echo( L_ShowUsageLine19_Text ) ' Line 19
  2752. WScript.Echo( L_ShowUsageLine20_Text ) ' Line 20
  2753. WScript.Echo( L_ShowUsageLine21_Text ) ' Line 21
  2754. WScript.Echo( L_ShowUsageLine22_Text ) ' Line 22
  2755. WScript.Echo( L_ShowUsageLine23_Text ) ' Line 23
  2756. WScript.Echo( L_ShowUsageLine24_Text ) ' Line 24
  2757. WScript.Echo( L_ShowUsageLine25_Text ) ' Line 25
  2758. End Sub
  2759. '******************************************************************************
  2760. '* Sub: ShowChangeUsage
  2761. '*
  2762. '* Purpose: Shows the correct usage to the user.
  2763. '*
  2764. '* Input: None
  2765. '*
  2766. '* Output: Help messages for the /Change o ption are displayed on screen.
  2767. '*
  2768. '******************************************************************************
  2769. Sub ShowChangeUsage()
  2770. WScript.Echo vbCr ' Line 1
  2771. WScript.Echo( L_ShowChangeUsageLine02_Text ) ' Line 2
  2772. WScript.Echo( L_ShowChangeUsageLine03_Text ) ' Line 3
  2773. WScript.Echo( L_ShowChangeUsageLine04_Text ) ' Line 4
  2774. WScript.Echo vbCr ' Line 5
  2775. WScript.Echo( L_UsageDescription_Text ) ' Line 6
  2776. WScript.Echo( L_ShowChangeUsageLine07_Text ) ' Line 7
  2777. WScript.Echo vbCr ' Line 8
  2778. WScript.Echo( L_UsageParamList_Text ) ' Line 9
  2779. WScript.Echo( L_UsageMachineName_Text ) ' Line 10
  2780. WScript.Echo vbCr ' Line 11
  2781. WScript.Echo( L_UsageUserNameLine1_Text ) ' Line 12
  2782. WScript.Echo( L_UsageUserNameLine2_Text ) ' Line 13
  2783. WScript.Echo vbCr ' Line 14
  2784. WScript.Echo( L_UsagePasswordLine1_Text ) ' Line 15
  2785. WScript.Echo( L_UsagePasswordLine2_Text ) ' Line 16
  2786. WScript.Echo vbCr ' Line 17
  2787. WScript.Echo( L_ShowChangeUsageLine18_Text ) ' Line 18
  2788. WScript.Echo( L_ShowChangeUsageLine19_Text ) ' Line 19
  2789. WScript.Echo vbCr ' Line 20
  2790. WScript.Echo( L_ShowChangeUsageLine21_Text ) ' Line 21
  2791. WScript.Echo( L_ShowChangeUsageLine22_Text ) ' Line 22
  2792. WScript.Echo vbCr ' Line 23
  2793. WScript.Echo( L_ShowChangeUsageLine24_Text ) ' Line 24
  2794. WScript.Echo( L_ShowChangeUsageLine25_Text ) ' Line 25
  2795. WScript.Echo( L_ShowChangeUsageLine26_Text ) ' Line 26
  2796. WScript.Echo( L_ShowChangeUsageLine27_Text ) ' Line 27
  2797. WScript.Echo vbCr ' Line 28
  2798. WScript.Echo( L_UsageExamples_Text ) ' Line 29
  2799. WScript.Echo( L_ShowChangeUsageLine30_Text ) ' Line 30
  2800. WScript.Echo( L_ShowChangeUsageLine31_Text ) ' Line 31
  2801. WScript.Echo( L_ShowChangeUsageLine32_Text ) ' Line 32
  2802. WScript.Echo( L_ShowChangeUsageLine33_Text ) ' Line 33
  2803. WScript.Echo( L_ShowChangeUsageLine34_Text ) ' Line 34
  2804. WScript.Echo( L_ShowChangeUsageLine35_Text ) ' Line 35
  2805. End Sub
  2806. '******************************************************************************
  2807. '* Sub: ShowCreateUsage
  2808. '*
  2809. '* Purpose: Shows the correct usage to the user.
  2810. '*
  2811. '* Input: None
  2812. '*
  2813. '* Output: Help messages for the /Create option are displayed on screen.
  2814. '*
  2815. '******************************************************************************
  2816. Sub ShowCreateUsage()
  2817. WScript.Echo vbCr ' Line 1
  2818. WScript.Echo( L_ShowCreateUsageLine02_Text ) ' Line 2
  2819. WScript.Echo( L_ShowCreateUsageLine03_Text ) ' Line 3
  2820. WScript.Echo( L_ShowCreateUsageLine04_Text ) ' Line 4
  2821. WScript.Echo vbCr ' Line 5
  2822. WScript.Echo( L_UsageDescription_Text ) ' Line 6
  2823. WScript.Echo( L_ShowCreateUsageLine07_Text ) ' Line 7
  2824. WScript.Echo vbCr ' Line 8
  2825. WScript.Echo( L_UsageParamList_Text ) ' Line 9
  2826. WScript.Echo( L_UsageMachineName_Text ) ' Line 10
  2827. WScript.Echo vbCr ' Line 11
  2828. WScript.Echo( L_UsageUserNameLine1_Text ) ' Line 12
  2829. WScript.Echo( L_UsageUserNameLine2_Text ) ' Line 13
  2830. WScript.Echo vbCr ' Line 14
  2831. WScript.Echo( L_UsagePasswordLine1_Text ) ' Line 15
  2832. WScript.Echo( L_UsagePasswordLine2_Text ) ' Line 16
  2833. WScript.Echo vbCr ' Line 17
  2834. WScript.Echo( L_ShowCreateUsageLine18_Text ) ' Line 18
  2835. WScript.Echo( L_ShowCreateUsageLine19_Text ) ' Line 19
  2836. WScript.Echo vbCr ' Line 20
  2837. WScript.Echo( L_ShowCreateUsageLine21_Text ) ' Line 21
  2838. WScript.Echo( L_ShowCreateUsageLine22_Text ) ' Line 22
  2839. WScript.Echo vbCr ' Line 23
  2840. WScript.Echo( L_ShowCreateUsageLine24_Text ) ' Line 24
  2841. WScript.Echo( L_ShowCreateUsageLine25_Text ) ' Line 25
  2842. WScript.Echo( L_ShowCreateUsageLine26_Text ) ' Line 26
  2843. WScript.Echo( L_ShowCreateUsageLine27_Text ) ' Line 27
  2844. WScript.Echo vbCr ' Line 28
  2845. WScript.Echo( L_UsageExamples_Text ) ' Line 29
  2846. WScript.Echo( L_ShowCreateUsageLine30_Text ) ' Line 30
  2847. WScript.Echo( L_ShowCreateUsageLine31_Text ) ' Line 31
  2848. WScript.Echo( L_ShowCreateUsageLine32_Text ) ' Line 32
  2849. WScript.Echo( L_ShowCreateUsageLine33_Text ) ' Line 33
  2850. WScript.Echo( L_ShowCreateUsageLine34_Text ) ' Line 34
  2851. WScript.Echo( L_ShowCreateUsageLine35_Text ) ' Line 35
  2852. End Sub
  2853. '******************************************************************************
  2854. '* Sub: ShowDeleteUsage
  2855. '*
  2856. '* Purpose: Shows the correct usage to the user.
  2857. '*
  2858. '* Input: None
  2859. '*
  2860. '* Output: Help messages for the /Delete option are displayed on screen.
  2861. '*
  2862. '******************************************************************************
  2863. Sub ShowDeleteUsage()
  2864. WScript.Echo vbCr ' Line 1
  2865. WScript.Echo( L_ShowDeleteUsageLine02_Text ) ' Line 2
  2866. WScript.Echo( L_ShowDeleteUsageLine03_Text ) ' Line 3
  2867. WScript.Echo vbCr ' Line 4
  2868. WScript.Echo( L_UsageDescription_Text ) ' Line 5
  2869. WScript.Echo( L_ShowDeleteUsageLine06_Text ) ' Line 6
  2870. WScript.Echo vbCr ' Line 7
  2871. WScript.Echo( L_UsageParamList_Text ) ' Line 8
  2872. WScript.Echo( L_UsageMachineName_Text ) ' Line 9
  2873. WScript.Echo vbCr ' Line 10
  2874. WScript.Echo( L_UsageUserNameLine1_Text ) ' Line 11
  2875. WScript.Echo( L_UsageUserNameLine2_Text ) ' Line 12
  2876. WScript.Echo vbCr ' Line 13
  2877. WScript.Echo( L_UsagePasswordLine1_Text ) ' Line 14
  2878. WScript.Echo( L_UsagePasswordLine2_Text ) ' Line 15
  2879. WScript.Echo vbCr ' Line 16
  2880. WScript.Echo( L_ShowDeleteUsageLine17_Text ) ' Line 17
  2881. WScript.Echo( L_ShowDeleteUsageLine18_Text ) ' Line 18
  2882. WScript.Echo( L_ShowDeleteUsageLine19_Text ) ' Line 19
  2883. WScript.Echo vbCr ' Line 20
  2884. WScript.Echo( L_UsageExamples_Text ) ' Line 21
  2885. WScript.Echo( L_ShowDeleteUsageLine22_Text ) ' Line 22
  2886. WScript.Echo( L_ShowDeleteUsageLine23_Text ) ' Line 23
  2887. WScript.Echo( L_ShowDeleteUsageLine24_Text ) ' Line 24
  2888. WScript.Echo( L_ShowDeleteUsageLine25_Text ) ' Line 25
  2889. End Sub
  2890. '******************************************************************************
  2891. '* Sub: ShowQueryUsage
  2892. '*
  2893. '* Purpose: Shows the correct usage to the user.
  2894. '*
  2895. '* Input: None
  2896. '*
  2897. '* Output: Help messages for the /Query option are displayed on screen.
  2898. '*
  2899. '******************************************************************************
  2900. Sub ShowQueryUsage()
  2901. WScript.Echo vbCr ' Line 1
  2902. WScript.Echo( L_ShowQueryUsageLine02_Text ) ' Line 2
  2903. WScript.Echo( L_ShowQueryUsageLine03_Text ) ' Line 3
  2904. WScript.Echo vbCr ' Line 4
  2905. WScript.Echo( L_UsageDescription_Text ) ' Line 5
  2906. WScript.Echo( L_ShowQueryUsageLine06_Text ) ' Line 6
  2907. WScript.Echo vbCr ' Line 7
  2908. WScript.Echo( L_UsageParamList_Text ) ' Line 8
  2909. WScript.Echo( L_UsageMachineName_Text ) ' Line 9
  2910. WScript.Echo vbCr ' Line 10
  2911. WScript.Echo( L_UsageUserNameLine1_Text ) ' Line 11
  2912. WScript.Echo( L_UsageUserNameLine2_Text ) ' Line 12
  2913. WScript.Echo vbCr ' Line 13
  2914. WScript.Echo( L_UsagePasswordLine1_Text ) ' Line 14
  2915. WScript.Echo( L_UsagePasswordLine2_Text ) ' Line 15
  2916. WScript.Echo vbCr ' Line 16
  2917. WScript.Echo( L_ShowQueryUsageLine17_Text ) ' Line 17
  2918. WScript.Echo( L_ShowQueryUsageLine18_Text ) ' Line 18
  2919. WScript.Echo( L_ShowQueryUsageLine19_Text ) ' Line 19
  2920. WScript.Echo vbCr ' Line 20
  2921. WScript.Echo( L_UsageExamples_Text ) ' Line 21
  2922. WScript.Echo( L_ShowQueryUsageLine22_Text ) ' Line 22
  2923. WScript.Echo( L_ShowQueryUsageLine23_Text ) ' Line 23
  2924. WScript.Echo( L_ShowQueryUsageLine24_Text ) ' Line 24
  2925. WScript.Echo( L_ShowQueryUsageLine25_Text ) ' Line 25
  2926. WScript.Echo( L_ShowQueryUsageLine26_Text ) ' Line 26
  2927. WScript.Echo( L_ShowQueryUsageLine27_Text ) ' Line 27
  2928. End Sub
  2929. '+----------------------------------------------------------------------------+
  2930. '| End of the Script |
  2931. '+----------------------------------------------------------------------------+