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.

3517 lines
214 KiB

  1. '*********************************************************************************************
  2. '* File: ADPlus.vbs
  3. '* Version: 4.01
  4. '* Date: 5/29/2001
  5. '* Author: Robert Hensing, Solution Integration Engineering
  6. '* Purpose: AutodumpPlus is used to automatically generate memory dumps or log files containing
  7. '* scripted debug output usefull for troubleshooting N-tier WinDNA / .Net applications.
  8. '* Since WinDNA / .Net applications often encompass multiple, interdependent
  9. '* processes on one or more machines, when troubleshooting an application hang
  10. '* or crash it is often necessary to 'look' at all of the processes at the same time.
  11. '* AutodumpPlus allows you to profile an application that may be hanging by taking
  12. '* 'snapshots' (memory dumps, or debug log files) of that application and all of
  13. '* its processes, all at the same time. Multiple 'snapshots' can then be compared
  14. '* or analyzed to build a history or profile of an application over time.
  15. '*
  16. '* In addition to taking 'snapshots' of hung/non-responsive WinDNA / .Net applications
  17. '* AutodumpPlus can be used to troubleshoot applications that are crashing or throwing
  18. '* unhandled exceptions which can lead to a crash.
  19. '* Usage:
  20. '* AutodumpPlus has 3 modes of operation: 'Hang', 'Quick' and 'Crash' mode.
  21. '*
  22. '* In 'Hang' mode, AutodumpPlus assumes that a process is hung and it will attach a
  23. '* debugger to the process(s) specified on the command line with either the '-p'
  24. '* or '-pn' or '-iis' switches. After the debugger is attached to the process(s)
  25. '* AutodumpPlus will dump the memory of each process to a .dmp file for later analysis
  26. '* with a debugger (such as WinDBG). In this mode, processes are paused briefly
  27. '* while their memory is being dumped to a file and then resumed.
  28. '*
  29. '* In '-quick' mode AutodumpPlus assumes that a process is hung and it will attach a
  30. '* debugger to the process(s) specified on the command line with either the '-p'
  31. '* or '-pn' or '-iis' switches. After the debugger is attached to the process(s)
  32. '* AutodumpPlus will create text files for each process, containing commonly requested
  33. '* debug information, rather than dumping the entire memory for each process.
  34. '* 'Quick' mode is generally faster than 'Hang' mode, but requires symbols to be
  35. '* installed on the server where AutodumpPlus is running.
  36. '*
  37. '* In 'Crash' mode, AutodumpPlus assumes that a process will crash and it will attach
  38. '* a debugger to the process(s) specified on the command line with either the '-p'
  39. '* or '-pn' or '-iis' switches. After the debugger is attached to the process(s)
  40. '* AutodumpPlus will configure the debugger to log 'first chance' access violations
  41. '* (AV's) to a text file. When a 'second chance' access violation occurs, the
  42. '* processes memory is dumped to a .dmp file for analysis with a debugger such as
  43. '* WinDBG. In this mode, a debugger remains attached to the process(s) until the
  44. '* process exits or the debugger is exited by pressing CTRL-C in the minimized
  45. '* debugger window. When the process crashes, or CTRL-C is pressed, it will
  46. '* need to be re-started.
  47. '*
  48. '* For more information on using AutodumpPlus, please refer to the following KB:
  49. '* http://support.microsoft.com/support/kb/articles/q286/3/50.asp
  50. '***********************************************************************************************
  51. '*--------------------------------------------------------------------------
  52. '*
  53. '* Switches: '-hang', '-quick', '-crash', '-iis', '-p <PID>', '-pn <Process Name>
  54. '* '-pageheap', '-quiet', '-o <output directory>, '-notify <target>
  55. '*
  56. '*
  57. '* Required: ('-hang', or '-quick', or '-crash') AND ('-iis' or '-p' or '-pn')
  58. '*
  59. '* Optional: '-pageheap', '-quiet', '-o <outputdir>', '-notify <computer>'
  60. '*
  61. '* Examples: 'ADPlus -hang -iis', Produces memory dumps of IIS and all
  62. '* MTS/COM+ packages currently running.
  63. '*
  64. '* 'ADPlus -crash -p 1896', Attaches the debugger to process with PID
  65. '* 1896, and monitors it for 1st and 2nd
  66. '* chance access violations (crashes).
  67. '*
  68. '* 'ADPlus -quick -pn mmc.exe', Attaches the debugger to all instances
  69. '* of MMC.EXE and dumps debug information
  70. '* about these processes to a text file.
  71. '*
  72. '* 'ADPlus -?' or 'ADPlus -help': Displays detailed help.
  73. '*-------------------------------------------------------------------------------
  74. 'For more information on using AutodumpPlus, please refer to the following KB:
  75. 'http://support.microsoft.com/support/kb/articles/q286/3/50.asp
  76. '****************************************************************************
  77. Option Explicit
  78. ' These are AutodumpPlus's constants. By default, they should all be set to FALSE for performance reasons.
  79. ' These constants should only be set to TRUE for troubleshooting script problems or producing verbose debug
  80. ' information. Setting some of these constant to TRUE can have a performance impact on production servers.
  81. ' Set DEBUGGING = TRUE to turn on verbose debug output, usefull for troubleshooting ADPlus problems.
  82. Const DEBUGGING = FALSE
  83. ' Set Full_Dump_on_CONTRL_C to TRUE if you wish to have ADPlus produce a full memory dump (as opposed to a
  84. ' mini-memory dump) whenever CTRL-C is pressed to stop debugging, when running in 'crash' mode.
  85. ' Note: Depending upon the number of processes being monitored, this could generate a signifigant amount
  86. ' of memory dumps.
  87. Const Full_Dump_on_CONTRL_C = FALSE
  88. ' Set Create_Full_Dump_on_1st_Chance_Exception to TRUE if you wish to have ADPlus produce a full memory dump
  89. ' for the process each time a 1st chance exception is encountered. This is disabled by default for performance reasons.
  90. ' This is particulairly usefull if troubleshooting MTS or COM+ packages that get shut down after a 1st chance
  91. ' unhandled exception and do not reach a 2nd chance exception state before the process is shut down.
  92. Const Create_Full_Dump_on_1st_Chance_Exception = FALSE
  93. ' Set No_Dump_on_1st_Chance_Exception to TRUE if you wish to have ADPlus not produce any memory dumps
  94. ' when 1st chance exceptions are encountered. You may wish to do this if a very high rate of 1st chance
  95. ' exceptions is encountered (i.e. hundreds per minute) and the debugger is spending too much time producing mini-memory dumps
  96. ' causing the process to appear hung.
  97. ' NOTE: This constant should NOT be set to TRUE if Create_Full_Dump_on_1st_Chance_Exception (above) is ALSO set to TRUE
  98. ' as this would produce mutually exclusive behavior.
  99. Const No_Dump_on_1st_Chance_Exception = FALSE
  100. ' Set Dump_on_EH_Exceptions to TRUE if you wish to have ADPlus and produce a memory dump each time
  101. ' a C++ EH exception is encountered. This is disabled by default for performance reasons.
  102. Const Dump_on_EH_Exceptions = FALSE
  103. ' Set Dump_on_Unknown_Exceptions = TRUE if you wish to have ADPlus produce a memory dump each time
  104. ' an unknown exception is encountered. This is disabled by default for performance reasons.
  105. Const Dump_on_Unknown_Exceptions = FALSE
  106. ' Set Dump_Stack_on_DLL_Load = TRUE if you wish to have ADPlus dump the stack each time
  107. ' a DLL is loaded. This is disabled by default for performance reasons.
  108. Const Dump_Stack_on_DLL_Load = FALSE
  109. ' Set Dump_Stack_on_DLL_Load_Unload = TRUE if you wish to have ADPlus dump the stack each time
  110. ' a DLL is unloaded. This is disabled by default for performance reasons.
  111. Const Dump_Stack_on_DLL_UnLoad = FALSE
  112. ' Set No_CrashMode_Log = TRUE if you do NOT want ADPlus to create a log file in Crash Mode. If a process is generating
  113. ' a lot of exceptions, the debug log file created in crash mode could become quite large.
  114. Const No_CrashMode_Log = FALSE
  115. ' Set No_Free_Space_Checking = TRUE if you do NOT want ADPlus to check for free space before running. Certain RAID drivers
  116. ' can cause problems for the free space checking routines and it may be necessary to set this to TRUE to allow ADPlus to run.
  117. Const No_Free_Space_Checking = FALSE
  118. ' Set MAX_APPLICATIONS_TO_DEBUG to whatever upper limit you wish to impose on the -IIS switch.
  119. ' By default MAX_APPLICATIONS_TO_DEBUG defaults to 20 to limit the number of MTS or COM+ applications ADPlus will dump / monitor.
  120. ' NOTE: If there are 30 running MTS or COM+ applications and MAX_APPLICATIONS_TO_DEBUG is set to 20, ADPlus will display
  121. ' an error message indicating that there are too many applications running and it will quit.
  122. Const MAX_APPLICATIONS_TO_DEBUG = 20
  123. ' AudotumpPlus version
  124. Const VERSION = "4.01"
  125. ' The following constants are used by ADPlus for launching command shells and for the FileSystemObject.
  126. ' These constants should NOT be changed.
  127. Const MINIMIZE_NOACTIVATE = 7
  128. Const ACTIVATE_AND_DISPLAY = 1
  129. Const ForReading = 1, ForWriting = 2, ForAppending = 8
  130. Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
  131. ' AutodumpPlus's global variables
  132. Dim objArgs
  133. Dim objShell
  134. Dim objFileSystem
  135. Dim objFolder
  136. Dim HangMode
  137. Dim IISMode
  138. Dim QuickMode
  139. Dim QuietMode
  140. Dim CrashMode
  141. Dim PageHeapMode
  142. Dim OSwitchUsed
  143. Dim OSVer
  144. Dim OSBuildNumber
  145. Dim ComputerName
  146. Dim LogDir
  147. Dim CDBScriptsDir
  148. Dim CDBScriptName
  149. Dim InstallDir
  150. Dim ShortInstallDir
  151. Dim OutPutDir
  152. Dim OutPutDirShortPath
  153. Dim PackageCount
  154. Dim ErrorsDuringRuntime
  155. Dim HangDir
  156. Dim ShortHangDir
  157. Dim CrashDir
  158. Dim ShortCrashDir
  159. Dim IISPid
  160. Dim IISVer
  161. Dim IISProcessCount
  162. Dim GenericProcessPIDDictionary
  163. Dim GenericProcessNameDictionary
  164. Dim GenericModePID
  165. Dim GenericModeProcessName
  166. Dim DumpGenericProcess
  167. Dim DateTimeStamp
  168. Dim strPackageName
  169. Dim NotifyAdmin
  170. Dim NotifyTarget
  171. Dim LocalUserName
  172. Dim SymPathError
  173. Dim WinDir
  174. Dim EightDotThreePath
  175. Dim EightDotThreeValue
  176. ' Initialize global variables to default values
  177. Set GenericProcessPIDDictionary = CreateObject("Scripting.Dictionary")
  178. Set GenericProcessNameDictionary = CreateObject("Scripting.Dictionary")
  179. PackageCount = 0
  180. IISProcessCount = 0
  181. ErrorsDuringRuntime = false
  182. HangMode = false
  183. IISMode = false
  184. QuickMode = false
  185. QuietMode = false
  186. CrashMode = false
  187. GenericModePID = false
  188. GenericModeProcessName = false
  189. DumpGenericProcess = false
  190. OSwitchUsed = false
  191. NotifyAdmin = false
  192. EightDotThreePath = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\NTFSDisable8Dot3NameCreation"
  193. On Error Resume Next
  194. ' Get the installation directory name, used for verifying required files are present.
  195. Set objShell = createobject("Wscript.shell")
  196. Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  197. 'Check to see if NTFSDisable8Dot3NameCreation is set to 1
  198. 'If so then display an error and then exit to work around an issue with the Scripting.FileSystemObject's shortpath method.
  199. EightDotThreeValue = objShell.RegRead(EightDotThreePath)
  200. If DEBUGGING = TRUE Then
  201. wscript.echo "-----------------------"
  202. wscript.echo "In InitializeAutodump, checking the following registry key: " & EightDotThreePath
  203. wscript.echo "Err.number after reading key: " & err.number
  204. wscript.echo "Err.Description after reading key: " & err.description
  205. wscript.echo "-----------------------"
  206. err.clear
  207. End If
  208. If EightDotThreeValue = 1 Then 'Its TRUE, display an error and quit
  209. If QuietMode = False Then
  210. objShell.Popup "AutodumpPlus has detected that the following registry value " & EightDotThreePath & " is set to 1. AutodumpPlus will not work properly with 8.3 path's disabled. Please set this value to 0 and reboot the server before running AutodumpPlus again.",,"AutoDumpPlus", 0
  211. Else
  212. objShell.LogEvent 1, "AutodumpPlus has detected that the following registry value " & EightDotThreePath & " is set to 1. AutodumpPlus will not work properly with 8.3 path's disabled. Please set this value to 0 and reboot the server before running AutodumpPlus again."
  213. wscript.echo "AutodumpPlus has detected that the following registry value " & EightDotThreePath & " is set to 1. AutodumpPlus will not work properly with 8.3 path's disabled. Please set this value to 0 and reboot the server before running AutodumpPlus again."
  214. End If
  215. wscript.quit 1
  216. Else
  217. End If
  218. InstallDir = Left(wscript.scriptfullname,Len(wscript.scriptfullname)-Len(wscript.scriptname)-1)
  219. If DEBUGGING = TRUE Then
  220. wscript.echo "-----------------------------------------------------------"
  221. wscript.echo "Initial info, prior to calling any functions . . ."
  222. wscript.echo "The Wscript.scriptfullname is: " & Wscript.scriptfullname
  223. wscript.echo "The Install Directory is: " & InstallDir
  224. End If
  225. Set objFolder = objFileSystem.GetFolder(InstallDir)
  226. If DEBUGGING = TRUE Then
  227. Wscript.echo ""
  228. Wscript.echo "Trying to call objFileSystem.GetFolder on: " & InstallDir
  229. Wscript.echo "Error number after calling objFileSystem.GetFolder = " & err.number
  230. Wscript.echo "Error description: " & err.description
  231. If InstallDir = "" Then
  232. Wscript.quit 1
  233. End If
  234. End If
  235. err.clear
  236. ShortInstallDir = objFolder.ShortPath
  237. If DEBUGGING = TRUE Then
  238. Wscript.echo ""
  239. Wscript.echo "Trying to get ShortInstallDir . . ."
  240. Wscript.echo "Error number after calling objFolder.Shortpath = " & err.number
  241. Wscript.echo "Error description: " & err.description
  242. Wscript.echo "ShortInstallDir = " & ShortInstallDir
  243. wscript.echo " ------------------------------------------------------------"
  244. If ShortInstallDir = "" Then
  245. Wscript.quit 1
  246. End If
  247. End If
  248. If ShortInstallDir = "" Then
  249. objShell.Popup "AutodumpPlus encountered an error trying to get the short path name for the following directory: " & InstallDir & ". AutodumpPlus can not continue.",,"AutodumpPlus",0
  250. Wscript.quit 1
  251. End If
  252. err.clear
  253. '---------------------------------------------------------------------------------------------
  254. ' Function: Main
  255. ' The following subroutines and functions provide the core functionality for
  256. ' AutodumpPlus. All core functionality should be encapsulated in these sub's or functions.
  257. '---------------------------------------------------------------------------------------------
  258. Call GetArguments(objArgs)
  259. Call DetectOSVersion()
  260. Call GetDateTimeStamp()
  261. Call CheckFiles()
  262. Call InitializeAutodump()
  263. Call RunTlist()
  264. If IISMode = True Then
  265. If CrashMode = True Then
  266. Call DumpIIS(CrashDir & "\Process_List.txt", OSVer)
  267. Else
  268. Call DumpIIS(HangDir & "\Process_List.txt", OSVer)
  269. End If
  270. End If
  271. If DumpGenericProcess = True Then
  272. Call DumpAnyProc()
  273. End If
  274. Call ShowStatus(OSVer)
  275. ' ------------------------------------------------------------------------------------------
  276. '---------------------------------------------------------------------------------------------
  277. ' Function: GetArguments
  278. ' This function is responsible for getting the arguments the user passed in on the
  279. ' command line and storing them in an array.
  280. '---------------------------------------------------------------------------------------------
  281. Sub GetArguments(objArgs)
  282. On Error Resume Next
  283. If DEBUGGING = TRUE Then
  284. Wscript.echo ""
  285. Wscript.echo "-----------------------------------"
  286. Wscript.echo "In the GetArguments() function . . ."
  287. Wscript.echo "-----------------------------------"
  288. Wscript.echo ""
  289. End If
  290. Dim IsValidArgument
  291. Dim IsValidMode, IsValidAction
  292. Dim CallPrintHelp
  293. Dim x, y, z
  294. Dim Arg
  295. Dim EnvVar
  296. Dim Args
  297. Dim YesNo
  298. Dim objShell
  299. Dim SysEnv, UserEnv, VolatileEnv
  300. Dim Sympath
  301. Dim objFileSystem
  302. Dim oFS2
  303. Dim WShNetwork
  304. Dim CallDetectIISFromPNSwitch
  305. Set WShNetwork = CreateObject("Wscript.Network")
  306. Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  307. Set objShell = CreateObject("Wscript.Shell")
  308. IsValidArgument = False
  309. IsValidMode = False
  310. IsValidACtion = False
  311. x = 0
  312. y = 0
  313. z = 0
  314. OutPutDir = InstallDir
  315. ComputerName = WshNetwork.ComputerName
  316. Args = wscript.arguments.count
  317. If Wscript.arguments.Count > 0 Then
  318. Set objArgs = Wscript.Arguments
  319. For x=0 to Args-1
  320. If UCase(objArgs(x)) = "-QUIET" Then
  321. QuietMode = True
  322. IsValidArgument = True
  323. ElseIf UCase(objArgs(x)) = "-HANG" Then
  324. HangMode = True
  325. IsValidArgument = True
  326. IsValidMode = True
  327. ElseIf UCase(objArgs(x)) = "-QUICK" Then
  328. QuickMode = True
  329. HangMode = True
  330. IsValidArgument = True
  331. IsValidMode = True
  332. ElseIf UCase(objArgs(x)) = "-CRASH" Then
  333. CrashMode = True
  334. HangMode = False
  335. IsValidArgument = True
  336. IsValidMode = True
  337. ElseIf UCase(objArgs(x)) = "-PAGEHEAP" Then
  338. PageHeapMode = True
  339. IsValidArgument = True
  340. IsValidMode = True
  341. ElseIf UCase(objArgs(x)) = "-NOTIFY" Then
  342. If UCase(objArgs(x+1)) = "" or UCase(objArgs(x+1)) = " " or UCase(objArgs(x+1)) = "-PN" or UCase(objArgs(x+1)) = "-O" or UCase(objArgs(x+1)) = "-P" or UCase(objArgs(x+1)) = "-HANG" or UCase(objArgs(x+1)) = "-CRASH" or UCase(objArgs(x+1)) = "-QUICK" or UCase(objArgs(x+1)) = "-IIS" or UCase(objArgs(x+1)) = "-PAGEHEAP" or UCase(objArgs(x+1)) = "-QUIET" Then
  343. If QuietMode = False Then
  344. objShell.PopUp "No computer name or username was specified after the '-notify' switch on the command line. If the '-notify' switch is used, the next command line argument argument must specify a valid computer name or username for AutodumpPlus to send messages to (using the Messenger Service). It is recommended that you specify a computer name as it is generally more reliable than specifying a username.",,"AutodumpPlus",0
  345. Else
  346. Wscript.echo "No computer name or username was specified after the '-notify' switch on the command line. If the '-notify' switch is used, the next command line argument argument must specify a valid computer name or username for AutodumpPlus to send messages to (using the Messenger Service). It is recommended that you specify a computer name as it is generally more reliable than specifying a username."
  347. objShell.LogEvent 1, "No computer name or username was specified after the '-notify' switch on the command line. If the '-notify' switch is used, the next command line argument argument must specify a valid computer name or username for AutodumpPlus to send messages to (using the Messenger Service). It is recommended that you specify a computer name as it is generally more reliable than specifying a username."
  348. ErrorsDuringRuntime = True
  349. End If
  350. wscript.quit 1
  351. End If
  352. NotifyTarget = objArgs(x+1)
  353. NotifyAdmin = True
  354. IsValidArgument = True
  355. ElseIf UCase(objArgs(x)) = "-?" Then
  356. CallPrintHelp = True
  357. IsValidArgument = True
  358. ElseIf UCase(objArgs(x)) = "-HELP" Then
  359. CallPrintHelp = True
  360. IsValidArgument = True
  361. ElseIf UCase(objArgs(x)) = "-IIS" Then
  362. IISMode = True
  363. IsValidArgument = True
  364. IsValidAction = True
  365. ElseIf UCase(objArgs(x)) = "-O" Then
  366. If UCase(objArgs(x+1)) = "" or UCase(objArgs(x+1)) = " " or UCase(objArgs(x+1)) = "-PN" or UCase(objArgs(x+1)) = "-O" or UCase(objArgs(x+1)) = "-P" or UCase(objArgs(x+1)) = "-HANG" or UCase(objArgs(x+1)) = "-CRASH" or UCase(objArgs(x+1)) = "-QUICK" or UCase(objArgs(x+1)) = "-IIS" or UCase(objArgs(x+1)) = "-PAGEHEAP" or UCase(objArgs(x+1)) = "-QUIET" Then
  367. If QuietMode = False Then
  368. objShell.PopUp "No valid directory or UNC path was specified after the '-o' switch. If the '-o' switch is used, the next command line argument must specify a valid path for AutodumpPlus to output files to, i.e. '-o " & Chr(34) & "\\fileserver\share" & Chr(34) & "'",,"AutodumpPlus",0
  369. Else
  370. Wscript.echo "No valid directory or UNC path was specified after the '-o' switch. If the '-o' switch is used, the next command line argument must specify a valid path for AutodumpPlus to output files to, i.e. '-o " & Chr(34) & "\\fileserver\share" & Chr(34) & "'"
  371. objShell.LogEvent 1, "No valid directory or UNC path was specified after the '-o' switch. If the '-o' switch is used, the next command line argument must specify a valid path for AutodumpPlus to output files to, i.e. '-o " & Chr(34) & "\\fileserver\share" & Chr(34) & "'"
  372. ErrorsDuringRuntime = True
  373. End If
  374. wscript.quit 1
  375. End If
  376. OutPutDir = objArgs(x+1)
  377. If DEBUGGING = TRUE Then
  378. wscript.echo "In GetArguments, OutPutDir = " & OutPutDir
  379. End If
  380. If InStr(1,OutPutDir,"\\",1) Then
  381. OutputDir = OutPutDir & "\" & WshNetwork.ComputerName
  382. End If
  383. If DEBUGGING = TRUE Then
  384. wscript.echo "In GetArguments, OutPutDir with server name = " & OutPutDir
  385. End If
  386. CreateDirectory(OutPutDir)
  387. Set oFS2 = objFileSystem.GetFolder(OutPutDir)
  388. OutPutDirShortPath = oFS2.ShortPath
  389. IsValidArgument = True
  390. OSwitchUsed = True
  391. ElseIf UCase(objArgs(x)) = "-P" Then
  392. If UCase(objArgs(x+1)) = "" or UCase(objArgs(x+1)) = " " or UCase(objArgs(x+1)) = "-PN" or UCase(objArgs(x+1)) = "-O" or UCase(objArgs(x+1)) = "-P" Then
  393. If QuietMode = False Then
  394. objShell.PopUp "If the '-p' switch is used, you must specify the PID (Process ID) of a process to attach to, i.e. '-p 1896'",,"AutodumpPlus",0
  395. Else
  396. Wscript.echo "If the '-p' switch is used, you must specify the PID (Process ID) of a process to attach to, i.e. '-p 1896'"
  397. objShell.LogEvent 1, "If the '-p' switch is used, you must specify the PID (Process ID) of a process to attach to, i.e. '-p 1896'"
  398. ErrorsDuringRuntime = True
  399. End If
  400. wscript.quit 1
  401. End If
  402. GenericProcessPIDDictionary.add y, objArgs(x+1)
  403. y = y+1
  404. DumpGenericProcess = True
  405. GenericModePID = True
  406. IsValidArgument = True
  407. IsValidAction = True
  408. ElseIf UCase(objArgs(x)) = "-PN" Then
  409. If UCase(objArgs(x+1)) = "" or UCase(objArgs(x+1)) = " " or UCase(objArgs(x+1)) = "-P" or UCase(objArgs(x+1)) = "-O" or UCase(objArgs(x+1)) = "-PN" Then
  410. If QuietMode = False Then
  411. objShell.PopUp "If the '-pn' switch is used, you must specify the name of a process to attach to, i.e. '-pn mmc.exe'",,"AutodumpPlus",0
  412. Else
  413. Wscript.echo "If the '-pn' switch is used, you must specify the name of a process to attach to, i.e. '-pn mmc.exe'"
  414. objShell.LogEvent 1, "If the '-pn' switch is used, you must specify the name of a process to attach to, i.e. '-pn mmc.exe'"
  415. ErrorsDuringRuntime = True
  416. End If
  417. wscript.quit 1
  418. End If
  419. GenericProcessNameDictionary.add z, objArgs(x+1)
  420. z = z+1
  421. DumpGenericProcess = True
  422. GenericModeProcessName = True
  423. IsValidArgument = True
  424. IsValidAction = True
  425. End If
  426. Next
  427. Else 'No arguments were typed, display the usage info . . .
  428. 'After getting the arguments, the first thing we need to do is determine the script engine that is running AutodumpPlus.
  429. Call DetectScriptEngine()
  430. Call PrintUsage()
  431. End If
  432. 'Check to see if PageHeapMode is being used in Crash mode or hang mode. If used in hang mode, display an error and quit.
  433. If PageHeapMode = True and CrashMode = False Then
  434. If QuietMode = False Then
  435. objShell.PopUp "AutodumpPlus must be running in crash mode ('-crash' switch) in order to use the '-pageheap' switch. Please re-run AutodumpPlus using the '-crash' switch if you are trying to use Pageheap to troubleshoot heap corruption.",,"AutodumpPlus",0
  436. Else
  437. Wscript.echo "AutodumpPlus must be running in crash mode ('-crash' switch) in order to use the '-pageheap' switch. Please re-run AutodumpPlus using the '-crash' switch if you are trying to use Pageheap to troubleshoot heap corruption."
  438. objShell.LogEvent 1, "AutodumpPlus must be running in crash mode ('-crash' switch) in order to use the '-pageheap' switch. Please re-run AutodumpPlus using the '-crash' switch if you are trying to use Pageheap to troubleshoot heap corruption."
  439. ErrorsDuringRuntime = True
  440. End If
  441. wscript.quit 1
  442. End If
  443. 'Check to see if the -notify switch is being used in 'Hang' mode, if so display an error.
  444. If NotifyAdmin = True and HangMode = True Then
  445. If QuietMode = False Then
  446. objShell.PopUp "The '-notify' switch is only valid when running in crash mode. Please try running AutodumpPlus again in 'crash' mode or without the '-notify' switch.",,"AutodumpPlus",0
  447. ErrorsDuringRuntime = True
  448. wscript.quit 1
  449. Else
  450. Wscript.echo "The '-notify' switch is only valid when running in crash mode. Please try running AutodumpPlus again in 'crash' mode or without the '-notify' switch."
  451. objShell.LogEvent 1, "The '-notify' switch is only valid when running in crash mode. Please try running AutodumpPlus again in 'crash' mode or without the '-notify' switch."
  452. ErrorsDuringRuntime = True
  453. wscript.quit 1
  454. End If
  455. End If
  456. 'After getting the arguments, the first thing we need to do is determine the script engine that is running AutodumpPlus.
  457. Call DetectScriptEngine()
  458. 'Check to see whether the '-iis' switch was used along with the '-pn' switch for any duplicate process dumping / monitoring
  459. 'objShell.Popup "Debug Break", 0
  460. For Arg = 0 to objArgs.Count -1
  461. If IISMode = True Then
  462. DetectIISVersion()
  463. End If
  464. If IISMode = True and UCase(objArgs(Arg)) = "DLLHOST.EXE" Then
  465. If HangMode = True or QuickMode = True Then
  466. If QuietMode = False Then
  467. objShell.Popup "You have specified the '-iis' switch on the command line in addition to '-pn dllhost.exe'. The '-iis' switch when used in 'hang' or 'quick' mode will automatically dump all running instances of dllhost.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to dump the System package, please use the '-p' switch and specify the PID for the System package.",,"Autodump",0
  468. Wscript.quit 1
  469. Else
  470. wscript.echo "You have specified the '-iis' switch on the command line in addition to '-pn dllhost.exe'. The '-iis' switch when used in 'hang' or 'quick' mode will automatically dump all running instances of dllhost.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to dump the System package, please use the '-p' switch and specify the PID for the System package."
  471. objShell.logevent 1, "You have specified the '-iis' switch on the command line in addition to '-pn dllhost.exe'. The '-iis' switch when used in 'hang' or 'quick' mode will automatically dump all running instances of dllhost.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to dump the System package, please use the '-p' switch and specify the PID for the System package."
  472. Wscript.quit 1
  473. End If
  474. Else
  475. If QuietMode = False Then
  476. objShell.Popup "You have specified the '-iis' switch on the command line in addition to '-pn dllhost.exe'. The '-iis' switch when used in 'crash' mode will automatically attach a debugger to all running instances of dllhost.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to attach a debugger to the System package, please use the '-p' switch and specify the PID for the System package.",,"Autodump",0
  477. Wscript.quit 1
  478. Else
  479. wscript.echo "You have specified the '-iis' switch on the command line in addition to '-pn dllhost.exe'. The '-iis' switch when used in 'crash' mode will automatically attach a debugger to all running instances of dllhost.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to attach a debugger to the System package, please use the '-p' switch and specify the PID for the System package."
  480. objShell.logevent 1, "You have specified the '-iis' switch on the command line in addition to '-pn dllhost.exe'. The '-iis' switch when used in 'crash' mode will automatically attach a debugger to all running instances of dllhost.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to attach a debugger to the System package, please use the '-p' switch and specify the PID for the System package."
  481. Wscript.quit 1
  482. End If
  483. End If
  484. ElseIf IISMode = True and UCase(objArgs(Arg)) = "MTX.EXE" Then
  485. If HangMode = True or QuickMode = True Then
  486. If QuietMode = False Then
  487. objShell.Popup "You have specified the '-iis' switch on the command line in addition to '-pn mtx.exe'. The '-iis' switch when used in 'hang' or 'quick' mode will automatically dump all running instances of mtx.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to dump the System package, please use the '-p' switch and specify the PID for the System package.",,"Autodump",0
  488. Wscript.quit 1
  489. Else
  490. wscript.echo "You have specified the '-iis' switch on the command line in addition to '-pn mtx.exe'. The '-iis' switch when used in 'hang' or 'quick' mode will automatically dump all running instances of mtx.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to dump the System package, please use the '-p' switch and specify the PID for the System package."
  491. objShell.logevent 1, "You have specified the '-iis' switch on the command line in addition to '-pn mtx.exe'. The '-iis' switch when used in 'hang' or 'quick' mode will automatically dump all running instances of mtx.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to dump the System package, please use the '-p' switch and specify the PID for the System package."
  492. Wscript.quit 1
  493. End If
  494. Else
  495. If QuietMode = False Then
  496. objShell.Popup "You have specified the '-iis' switch on the command line in addition to '-pn mtx.exe'. The '-iis' switch when used in 'crash' mode will automatically attach a debugger to all running instances of mtx.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to attach a debugger to the System package, please use the '-p' switch and specify the PID for the System package.",,"Autodump",0
  497. Wscript.quit 1
  498. Else
  499. wscript.echo "You have specified the '-iis' switch on the command line in addition to '-pn mtx.exe'. The '-iis' switch when used in 'crash' mode will automatically attach a debugger to all running instances of mtx.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to attach a debugger to the System package, please use the '-p' switch and specify the PID for the System package."
  500. objShell.logevent 1, "You have specified the '-iis' switch on the command line in addition to '-pn mtx.exe'. The '-iis' switch when used in 'crash' mode will automatically attach a debugger to all running instances of mtx.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to attach a debugger to the System package, please use the '-p' switch and specify the PID for the System package."
  501. Wscript.quit 1
  502. End If
  503. End If
  504. ElseIf IISMode = True and UCase(objArgs(Arg)) = "INETINFO.EXE" Then
  505. If HangMode = True or QuickMode = True Then
  506. If QuietMode = False Then
  507. objShell.Popup "You have specified the '-iis' switch on the command line in addition to '-pn inetinfo.exe'. The '-iis' switch when used in 'hang' or 'quick' mode will automatically dump all running instances of inetinfo.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to dump the System package, please use the '-p' switch and specify the PID for the System package.",,"Autodump",0
  508. Wscript.quit 1
  509. Else
  510. wscript.echo "You have specified the '-iis' switch on the command line in addition to '-pn inetinfo.exe'. The '-iis' switch when used in 'hang' or 'quick' mode will automatically dump all running instances of inetinfo.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to dump the System package, please use the '-p' switch and specify the PID for the System package."
  511. objShell.logevent 1, "You have specified the '-iis' switch on the command line in addition to '-pn inetinfo.exe'. The '-iis' switch when used in 'hang' or 'quick' mode will automatically dump all running instances of inetinfo.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to dump the System package, please use the '-p' switch and specify the PID for the System package."
  512. Wscript.quit 1
  513. End If
  514. Else
  515. If QuietMode = False Then
  516. objShell.Popup "You have specified the '-iis' switch on the command line in addition to '-pn inetinfo.exe'. The '-iis' switch when used in 'crash' mode will automatically attach a debugger to all running instances of inetinfo.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to attach a debugger to the System package, please use the '-p' switch and specify the PID for the System package.",,"Autodump",0
  517. Wscript.quit 1
  518. Else
  519. wscript.echo "You have specified the '-iis' switch on the command line in addition to '-pn inetinfo.exe'. The '-iis' switch when used in 'crash' mode will automatically attach a debugger to all running instances of inetinfo.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to attach a debugger to the System package, please use the '-p' switch and specify the PID for the System package."
  520. objShell.logevent 1, "You have specified the '-iis' switch on the command line in addition to '-pn inetinfo.exe'. The '-iis' switch when used in 'crash' mode will automatically attach a debugger to all running instances of inetinfo.exe. Please run AutodumpPlus again without the '-pn' switch. If you are trying to attach a debugger to the System package, please use the '-p' switch and specify the PID for the System package."
  521. Wscript.quit 1
  522. End If
  523. End If
  524. End If
  525. Next
  526. 'Check to see if we need to print the help screen
  527. If CallPrintHelp = True Then
  528. PrintHelp()
  529. End If
  530. If IsValidArgument = False Then 'No valid arguments were passed in, display the usage info . . .
  531. Call PrintUsage()
  532. QuickMode = False
  533. QuietMode = False
  534. CrashMode = False
  535. End If
  536. If not (IsValidMode and IsValidAction) Then
  537. PrintUsage()
  538. End If
  539. If HangMode = True AND CrashMode = True Then 'Can't run in both hang and crash mode at the same time
  540. Call PrintUsage()
  541. ElseIf CrashMode = True AND QuickMode = True Then 'Can't run in both crash and quick mode at the same time
  542. Call PrintUsage()
  543. ElseIf HangMode <> True and CrashMode <> True and QuickMode <> True Then 'You have to at least be running in hang, crash, or quick mode
  544. Call PrintUsage()
  545. End If
  546. Set SysEnv = objShell.Environment("SYSTEM")
  547. Set UserEnv = objShell.Environment("USER")
  548. If QuickMode = True or CrashMode = True Then
  549. If SysEnv("_NT_SYMBOL_PATH") <> "" Then
  550. Sympath = SysEnv("_NT_SYMBOL_PATH")
  551. ElseIf UserEnv("_NT_SYMBOL_PATH") <> "" Then
  552. Sympath = UserEnv("_NT_SYMBOL_PATH")
  553. Else
  554. If QuietMode = False Then
  555. objShell.Popup "WARNING! An '_NT_SYMBOL_PATH' environment variable is not set, as a result AutodumpPlus will be forced to use 'export' symbols (if present) to resolve function names in the stack trace information for each thread listed in the log file for the processes being debugged. To resolve this warning, please copy the appropriate symbols to a directory on the server and then create an environment variable with a name of '_NT_SYMBOL_PATH' and a value containing the path to the proper symbols (i.e. c:\winnt\symbols) before running AutodumpPlus in quick or crash modes again. NOTE: After creating the '_NT_SYMBOL_PATH' system environment variable you will need to close the current command shell and open a new one before running AutodumpPlus again.",,"AutodumpPlus",0
  556. SymPathError = True
  557. ErrorsDuringScriptRuntime = True
  558. Else
  559. Wscript.echo "WARNING! An '_NT_SYMBOL_PATH' environment variable is not set."
  560. Wscript.echo "Please check the application event log or the AutodumpPlus-report.txt"
  561. Wscript.echo "for more details."
  562. Wscript.echo ""
  563. objShell.LogEvent 1, "WARNING! An '_NT_SYMBOL_PATH' environment variable is not set, as a result AutodumpPlus will be forced to use 'export' symbols (if present) to resolve function names in the stack trace information for each thread listed in the log file for the processes being debugged. To resolve this warning, please copy the appropriate symbols to a directory on the server and then create an environment variable with a name of '_NT_SYMBOL_PATH' and a value containing the path to the proper symbols (i.e. c:\winnt\symbols) before running AutodumpPlus in quick or crash modes again. NOTE: After creating the '_NT_SYMBOL_PATH' system environment variable you will need to close the current command shell and open a new one before running AutodumpPlus again."
  564. SymPathError = True
  565. End If
  566. 'Wscript.Quit
  567. End If
  568. End If
  569. 'If not running on Windows XP, check to see if the user account is running inside of a terminal server session.
  570. 'If so, and the -crash switch is being used, display an error since 'crash' mode doesn't work inside of a terminal
  571. 'server session on NT 4.0 or Windows 2000.
  572. 'If the server doesn't have terminal services installed, we can assume they aren't running ADPlus in a TS session
  573. 'so check for that first.
  574. 'I have not tested this on NT 4.0 TSE so I'm not sure if this code will work properly on NT 4.0 TSE boxes.
  575. Call DetectOSVersion
  576. If CInt(OSBuildNumber) <= 2195 Then
  577. Dim TermServDeviceDesc
  578. Dim TermServKey
  579. TermServKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\RDPDR\0000\DeviceDesc"
  580. err.clear
  581. TermServDeviceDesc = objShell.RegRead(TermServKey)
  582. If err.number <> -2147024894 Then 'The TS RDPDR key was found, Terminal services is installed, check to make sure the user isn't in a TS session.
  583. Set VolatileEnv = objShell.Environment("PROCESS")
  584. If (UCase(VolatileEnv("SESSIONNAME")) <> "CONSOLE" and VolatileEnv("SESSIONNAME") <> "") and (CrashMode = True) Then
  585. If QuietMode = False Then
  586. objShell.Popup "AutodumpPlus has detected that you are attempting to run in 'Crash' mode, but this account is currently logged into terminal server session ID: " & UCase(VolatileEnv("SESSIONNAME")) & ". 'Crash' mode (invoked via the '-crash' switch) will not work inside a terminal server session. To run AutodumpPlus in 'Crash' mode, please log in locally at the console.",,"AutodumpPlus",0
  587. Else
  588. Wscript.echo "AutodumpPlus has detected that you are attempting to run in 'Crash' mode, but this account is currently logged into terminal server session ID: " & UCase(VolatileEnv("SESSIONNAME")) & ". 'Crash' mode (invoked via the '-crash' switch) will not work inside a terminal server session. To run AutodumpPlus in 'Crash' mode, please log in locally at the console."
  589. objShell.LogEvent 1, "AutodumpPlus has detected that you are attempting to run in 'Crash' mode, but this account is currently logged into terminal server session ID: " & UCase(VolatileEnv("SESSIONNAME")) & ". 'Crash' mode (invoked via the '-crash' switch) will not work inside a terminal server session. To run AutodumpPlus in 'Crash' mode, please log in locally at the console."
  590. ErrorsDuringRuntime = True
  591. End If
  592. Wscript.Quit
  593. End If
  594. End If
  595. End If
  596. 'Get the locally logged on users name for use with the !Net_send command
  597. LocalUserName = VolatileEnv("USERNAME")
  598. If DEBUGGING = TRUE Then
  599. wscript.echo "--------------------------------"
  600. wscript.echo "In GetArguments(), QuickMode = " & QuickMode
  601. wscript.echo "In GetArguments(), QuietMode = " & QuietMode
  602. wscript.echo "In GetArguments(), CrashMode = " & CrashMode
  603. wscript.echo "In GetArguments(), HangMode = " & HangMode
  604. wscript.echo "In GetArguments(), LocaluserName = " & LocalUserName
  605. wscript.echo "--------------------------------"
  606. End If
  607. End Sub
  608. '---------------------------------------------------------------------------------------------
  609. ' Function: GetDateTimeStamp
  610. ' This function is responsible for getting the unique Date / Time stamp used for
  611. ' creating unique directory / file names.
  612. ' To Change the names of the output directories, edit them below.
  613. '---------------------------------------------------------------------------------------------
  614. Function GetDateTimeStamp()
  615. On Error Resume Next
  616. If DEBUGGING = TRUE Then
  617. Wscript.echo ""
  618. Wscript.echo "-----------------------------------"
  619. Wscript.echo "In the GetDateTimeStamp() function . . ."
  620. Wscript.echo "-----------------------------------"
  621. Wscript.echo ""
  622. End If
  623. Dim AMorPM
  624. Dim Seconds
  625. Dim Minutes
  626. Dim Hours
  627. Dim theDay
  628. Dim theMonth
  629. Hours = Hour(Now)
  630. Minutes = Minute(Now)
  631. Seconds = Second(Now)
  632. theDay = Day(Now)
  633. theMonth = Month(Now)
  634. AMorPM = Right(Now(),2)
  635. If Len(Hours) = 1 Then Hours = "0" & Hours
  636. If Len(Minutes) = 1 Then Minutes = "0" & Minutes
  637. If Len(Seconds) = 1 Then Seconds = "0" & Seconds
  638. If Len(theDay) = 1 Then theDay = "0" & theDay
  639. If Len(theMonth) = 1 Then theMonth = "0" & theMonth
  640. DateTimeStamp = "Date_" & theMonth & "-" & theDay & "-" & Year(Now) & "__Time_" & Hours & "-" & Minutes & "-" & Seconds & AMorPM
  641. If DEBUGGING = TRUE Then
  642. Wscript.echo ""
  643. Wscript.echo "-----------------------------------"
  644. Wscript.echo "In GetDateTimeStamp(), DateTimeStamp = " & DateTimeStamp
  645. Wscript.echo "-----------------------------------"
  646. Wscript.echo ""
  647. End If
  648. If QuickMode = True Then
  649. HangDir = OutPutDir & "\Quick_Hang_Mode__" + DateTimeStamp
  650. Else
  651. HangDir = OutPutDir & "\Normal_Hang_Mode__" + DateTimeStamp
  652. CrashDir = OutPutDir + "\Crash_Mode__" + DateTimeStamp
  653. End If
  654. End Function
  655. '---------------------------------------------------------------------------------------------
  656. ' Function: CheckFiles
  657. ' This function is responsible for ensuring that all the required files are
  658. ' installed in the 'InstallDir'. If files are missing, display an error or
  659. ' log an error to the event log if running in quiet mode.
  660. '---------------------------------------------------------------------------------------------
  661. Sub CheckFiles()
  662. On Error Resume Next
  663. If DEBUGGING = TRUE Then
  664. Wscript.echo ""
  665. Wscript.echo "-----------------------------------"
  666. Wscript.echo "In the CheckFiles() function . . ."
  667. Wscript.echo "-----------------------------------"
  668. Wscript.echo ""
  669. End If
  670. Dim objFS
  671. Dim objShell
  672. Set objFS = CreateObject("Scripting.FileSystemObject")
  673. Set objShell = CreateObject("Wscript.Shell")
  674. 'Make sure CDB.EXE & ADPlus.vbs are in the right place. If its not it could mean ADPlus.vbs isn't running from the debuggers directory.
  675. If not FileExists(InstallDir & "\cdb.exe") Then
  676. If QuietMode = False Then
  677. objShell.popup "AutodumpPlus is not configured properly. Either the file CDB.EXE is missing from " & InstallDir & " or ADPlus.vbs is not running from the debuggers installation directory. Please place ADPlus.vbs in the debuggers installation directory or try re-installing the Debugging Tools for Windows.",,"AutodumpPlus",0
  678. Else
  679. objShell.LogEvent 1, "AutodumpPlus is not configured properly. Either the file CDB.EXE is missing from " & InstallDir & " or ADPlus.vbs is not running from the debuggers installation directory. Please place ADPlus.vbs in the debuggers installation directory or try re-installing the Debugging Tools for Windows."
  680. wscript.echo "AutodumpPlus is not configured properly. Either the file CDB.EXE is missing from " & InstallDir & " or ADPlus.vbs is not running from the debuggers installation directory. Please place ADPlus.vbs in the debuggers installation directory or try re-installing the Debugging Tools for Windows."
  681. End If
  682. wscript.quit 1
  683. End If
  684. 'Make sure the NT 4.0 debug extensions are installed
  685. If OSVer = "4.0" Then
  686. If not FileExists(InstallDir & "\nt4fre\userexts.dll") Then
  687. If QuietMode = False Then
  688. objShell.popup "AutodumpPlus is not configured properly. The file userexts.dll is missing from " & InstallDir & "\nt4fre" & ". Please re-install the Debugging Tools for Windows.",,"AutodumpPlus",0
  689. Else
  690. objShell.LogEvent 1, "AutodumpPlus is not configured properly. The file userexts.dll is missing from " & InstallDir & "\nt4fre" & ". Please re-install the Debugging Tools for Windows."
  691. wscript.echo "AutodumpPlus is not configured properly. The file userexts.dll is missing from " & InstallDir & "\nt4fre" & ". Please re-install the Debugging Tools for Windows."
  692. End If
  693. wscript.quit 1
  694. End If
  695. End If
  696. 'Make sure the Windows 2000 debug extensions are installed
  697. If CInt(OSBuildNumber) = 2195 Then
  698. If not FileExists(InstallDir & "\w2kfre\userexts.dll") Then
  699. If QuietMode = False Then
  700. objShell.popup "AutodumpPlus is not configured properly. The file userexts.dll is missing from " & InstallDir & "\w2kfre" & ". Please re-install the Debugging Tools for Windows.",,"AutodumpPlus",0
  701. Else
  702. objShell.LogEvent 1, "AutodumpPlus is not configured properly. The file userexts.dll is missing from " & InstallDir & "\w2kfre" & ". Please re-install the Debugging Tools for Windows."
  703. wscript.echo "AutodumpPlus is not configured properly. The file userexts.dll is missing from " & InstallDir & "\w2kfre" & ". Please re-install the Debugging Tools for Windows."
  704. End If
  705. wscript.quit 1
  706. End If
  707. End If
  708. 'Make sure the Windows XP debug extensions are installed
  709. 'If CInt(OSBuildNumber) > 2195 Then
  710. ' If not FileExists(InstallDir & "\w2001\userexts.dll") Then
  711. ' If QuietMode = False Then
  712. ' objShell.popup "AutodumpPlus is not configured properly. The file userexts.dll is missing from " & InstallDir & "\winxp" & ". Please re-install the Debugging Tools for Windows.",,"AutodumpPlus",0
  713. ' Else
  714. ' objShell.LogEvent 1, "AutodumpPlus is not configured properly. The file userexts.dll is missing from " & InstallDir & "\winxp" & ". Please re-install the Debugging Tools for Windows."
  715. ' wscript.echo "AutodumpPlus is not configured properly. The file userexts.dll is missing from " & InstallDir & "\winxp" & ". Please re-install the Debugging Tools for Windows."
  716. ' End If
  717. ' wscript.quit 1
  718. ' End If
  719. 'End If
  720. If not FileExists(InstallDir & "\cdb.exe") then
  721. If QuietMode = False Then
  722. objShell.popup "AutodumpPlus is not configured properly. The file cdb.exe is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows.",,"AutodumpPlus",0
  723. Else
  724. objShell.LogEvent 1, "AutodumpPlus is not configured properly. The file cdb.exe is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows."
  725. wscript.echo "AutodumpPlus is not configured properly. The file cdb.exe is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows."
  726. End If
  727. wscript.quit 1
  728. end If
  729. If not FileExists(InstallDir & "\dbgeng.dll") Then
  730. If QuietMode = False Then
  731. objShell.popup "AutodumpPlus is not configured properly. The file dbgeng.dll is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows.",,"AutodumpPlus",0
  732. Else
  733. objShell.LogEvent 1, "AutodumpPlus is not configured properly. The file dbgeng.dll is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows."
  734. wscript.echo "AutodumpPlus is not configured properly. The file dbgeng.dll is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows."
  735. End If
  736. wscript.quit 1
  737. end If
  738. If not FileExists(InstallDir & "\dbghelp.dll") then
  739. If QuietMode = False Then
  740. objShell.popup "AutodumpPlus is not configured properly. The file dbghelp.dll is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows.",,"AutodumpPlus",0
  741. Else
  742. objShell.LogEvent 1, "AutodumpPlus is not configured properly. The file dbghelp.dll is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows."
  743. wscript.echo "AutodumpPlus is not configured properly. The file dbghelp.dll is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows."
  744. End If
  745. wscript.quit 1
  746. end If
  747. If not FileExists(InstallDir & "\tlist.exe") then
  748. If QuietMode = False Then
  749. objShell.popup "AutodumpPlus is not configured properly. The file tlist.exe is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows.",,"AutodumpPlus",0
  750. Else
  751. objShell.LogEvent 1, "AutodumpPlus is not configured properly. The file tlist.exe is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows."
  752. wscript.echo "AutodumpPlus is not configured properly. The file tlist.exe is missing from " & InstallDir & ". Please re-install the Debugging Tools for Windows."
  753. End If
  754. wscript.quit 1
  755. end If
  756. set objFS= nothing
  757. set objShell = nothing
  758. End Sub
  759. '---------------------------------------------------------------------------------------------
  760. ' Function: InitializeAutodump
  761. ' This function is responsible for creating the crash or hang directories.
  762. ' The CreateDirectory function is called from this function and handles any
  763. ' permissions / directory creation problems by displaying an error or logging to
  764. ' the event log if running in quiet mode.
  765. '---------------------------------------------------------------------------------------------
  766. Sub InitializeAutodump()
  767. On Error Resume Next
  768. Dim versionFile
  769. Dim objFileSystem
  770. Dim oFSHang
  771. Dim oFSCrash
  772. On Error Resume Next
  773. If DEBUGGING = TRUE Then
  774. wscript.echo "-----------------------"
  775. wscript.echo "In InitializeAutodump"
  776. wscript.echo "-----------------------"
  777. End If
  778. set objFileSystem = CreateObject("Scripting.FileSystemObject")
  779. Set objShell = CreateObject("Wscript.Shell")
  780. If CrashMode = true Then
  781. If Create_Full_Dump_on_1st_Chance_Exception = TRUE and No_Dump_on_1st_Chance_Exception = TRUE Then
  782. If QuietMode = False Then
  783. objShell.popup "AutodumpPlus is not configured properly. The following constants: Create_Full_Dump_on_1st_Chance_Exception and No_Dump_on_1st_Chance_Exception are both set to TRUE and this is mutually exclusive behavior. Please set one or both of those constants to FALSE and try running AutodumpPlus again.",,"AutodumpPlus",0
  784. Else
  785. objShell.LogEvent 1, "AutodumpPlus is not configured properly. The following constants: Create_Full_Dump_on_1st_Chance_Exception and No_Dump_on_1st_Chance_Exception are both set to TRUE and this is mutually exclusive behavior. Please set one or both of those constants to FALSE and try running AutodumpPlus again."
  786. wscript.echo "AutodumpPlus is not configured properly. The following constants: Create_Full_Dump_on_1st_Chance_Exception and No_Dump_on_1st_Chance_Exception are both set to TRUE and this is mutually exclusive behavior. Please set one or both of those constants to FALSE and try running AutodumpPlus again."
  787. End If
  788. wscript.quit 1
  789. End If
  790. Call CreateDirectory(CrashDir) ' Create the new crash mode folder.
  791. Set oFSCrash = objFileSystem.GetFolder(CrashDir)
  792. ShortCrashDir = oFSCrash.ShortPath 'Set the short file name.
  793. If DEBUGGING = TRUE Then
  794. wscript.echo "In InitializeAutodump(), CrashDir = " & CrashDir
  795. wscript.echo "In InitializeAutodump(), ShortCrashDir = " & ShortCrashDir
  796. Wscript.echo "Error number after calling oFSCrash.Shortpath = " & err.number
  797. Wscript.echo "Error description: " & err.description
  798. wscript.echo " ------------------------------------------------------------"
  799. If ShortCrashDir = "" Then
  800. Wscript.quit 1
  801. End If
  802. End If
  803. If ShortCrashDir = "" Then
  804. If QuietMode = False Then
  805. objShell.Popup "AutodumpPlus encountered an error trying to get the short path name for the following directory: " & CrashDir & ". AutodumpPlus can not continue.",,"AutodumpPlus",0
  806. Else
  807. objShell.LogEvent 1, "AutodumpPlus encountered an error trying to get the short path name for the following directory: " & CrashDir & ". AutodumpPlus can not continue."
  808. wscript.echo "AutodumpPlus encountered an error trying to get the short path name for the following directory: " & CrashDir & ". AutodumpPlus can not continue."
  809. End If
  810. DeleteDirectory(CrashDir)
  811. Wscript.quit 1
  812. End If
  813. Else
  814. Call CreateDirectory(HangDir) ' Create the new hang mode folder.
  815. Set oFSHang = objFileSystem.GetFolder(HangDir)
  816. ShortHangDir = oFSHang.ShortPath 'Set the short file name.
  817. If DEBUGGING = TRUE Then
  818. wscript.echo "In InitializeAutodump(), HangDir = " & HangDir
  819. wscript.echo "In InitializeAutodump(), ShortHangDir = " & ShortHangDir
  820. Wscript.echo "Error number after calling oFSHang.Shortpath = " & err.number
  821. Wscript.echo "Error description: " & err.description
  822. wscript.echo " ------------------------------------------------------------"
  823. If ShortHangDir = "" Then
  824. Wscript.quit 1
  825. End If
  826. End If
  827. If ShortHangDir = "" Then
  828. If QuietMode = False Then
  829. objShell.Popup "AutodumpPlus encountered an error trying to get the short path name for the following directory: " & HangDir & ". AutodumpPlus can not continue.",,"AutodumpPlus",0
  830. Else
  831. objShell.LogEvent 1, "AutodumpPlus encountered an error trying to get the short path name for the following directory: " & HangDir & ". AutodumpPlus can not continue."
  832. wscript.echo "AutodumpPlus encountered an error trying to get the short path name for the following directory: " & HangDir & ". AutodumpPlus can not continue."
  833. End If
  834. DeleteDirectory(HangDir)
  835. Wscript.quit 1
  836. End If
  837. End If
  838. End Sub
  839. '---------------------------------------------------------------------------------------------
  840. ' Function: RunTlist
  841. ' This function is responsible for running tlist.exe -k to get a list of all
  842. ' running MTS or COM+ packages and piping it out to the appropriate text file.
  843. ' This function also runs EMCMD.EXE /T to get a list of all running processes.
  844. '---------------------------------------------------------------------------------------------
  845. Sub RunTlist()
  846. On Error Resume Next
  847. Dim objShell
  848. Dim objFileSystem
  849. Dim oFS2
  850. Dim objTextFile
  851. Dim strShell
  852. Dim objShellErrorLevel
  853. Dim DriveObject
  854. Dim Path
  855. Dim NewPath
  856. Dim PathArray
  857. Dim ServerName
  858. Dim ShareName
  859. Dim MinFreeSpace
  860. Set objShell = CreateObject("Wscript.Shell")
  861. Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  862. MinFreeSpace = 10000000 '10Mb free space should be enough to at least produce the .txt files and the output logs.
  863. If DEBUGGING = TRUE Then
  864. wscript.echo "-----------------------"
  865. wscript.echo "In RunTlist"
  866. wscript.echo ""
  867. End If
  868. 'Check the output directories drive to ensure there is enough free space for the files.
  869. If CrashMode = true Then
  870. If Left(ShortCrashDir,2) <> "\\" Then 'We are in crash mode but not logging to a UNC path.
  871. Set DriveObject = objFileSystem.GetDrive(Left(ShortCrashDir,1))
  872. If DEBUGGING = TRUE Then
  873. Wscript.echo "In RunTlist(), Err number after calling objFileSystem.GetDrive: " & err.number & " Err Description: " & err.description
  874. Wscript.echo "In RunTlist(), Free space = " & DriveObject.FreeSpace
  875. Wscript.echo "In RunTlist(), MinFreeSpace = " & MinFreeSpace
  876. Wscript.echo ""
  877. End If
  878. If No_Free_Space_Checking = False Then
  879. If DriveObject.FreeSpace < MinFreeSpace Then
  880. If DEBUGGING = TRUE Then
  881. Wscript.echo "In RunEcmdm(), No_Free_Space_Checking = FALSE"
  882. Wscript.echo "In RunTlist(), Err number after calling DriveObject.Freespace: " & err.number & " Err Description: " & err.description
  883. Wscript.echo "In RunTlist(), Free space = " & DriveObject.FreeSpace
  884. Wscript.echo "In RunTlist(), MinFreeSpace = " & MinFreeSpace
  885. Wscript.echo ""
  886. End If
  887. If QuietMode = False Then
  888. objShell.popup "AutodumpPlus has detected that there is not enough free space on the " & Left(ShortCrashDir,2) & " drive. AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again.",,"AutodumpPlus",0
  889. Else
  890. objShell.LogEvent 1, "AutodumpPlus has detected that there is not enough free space on the " & Left(ShortCrashDir,2) & " drive. AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again."
  891. wscript.echo "AutodumpPlus has detected that there is not enough free space on the " & Left(ShortCrashDir,2) & " drive. AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again."
  892. End If
  893. DeleteDirectory(ShortCrashDir)
  894. wscript.quit 1
  895. End If
  896. Else
  897. If DEBUGGING = TRUE Then
  898. Wscript.echo "In RunTlist(), No_Free_Space_Checking = TRUE"
  899. Wscript.echo "In RunTlist(), Call to DriveObject.Freespace skipped!"
  900. Wscript.echo "In RunTlist(), Err number after calling objFileSystem.GetDrive: " & err.number & " Err Description: " & err.description
  901. Wscript.echo ""
  902. End If
  903. End If
  904. Else 'We are in crash mode and logging to a UNC path
  905. Path = ShortCrashDir
  906. If DEBUGGING = TRUE Then
  907. Wscript.echo "Path = " & Path
  908. End If
  909. NewPath = Right(Path, Len(Path) - 2)
  910. If DEBUGGING = TRUE Then
  911. Wscript.echo "NewPath = " & NewPath
  912. End If
  913. PathArray = Split(NewPath, "\", -1)
  914. If DEBUGGING = TRUE Then
  915. Wscript.echo "ServerName = " & PathArray(0)
  916. End If
  917. ServerName = PathArray(0)
  918. If DEBUGGING = TRUE Then
  919. Wscript.echo "ShareName = " & PathArray(1)
  920. End If
  921. ShareName = PathArray(1)
  922. NewPath = "\\" & ServerName & "\" & ShareName
  923. If DEBUGGING = TRUE Then
  924. Wscript.echo "NewPath = " & NewPath
  925. End If
  926. Set DriveObject = objFileSystem.GetDrive(NewPath)
  927. If No_Free_Space_Checking = False Then
  928. If DriveObject.FreeSpace < MinFreeSpace Then
  929. If DEBUGGING = TRUE Then
  930. Wscript.echo "In RunEcmdm(), No_Free_Space_Checking = FALSE"
  931. Wscript.echo "In RunTlist(), Err number after calling DriveObject.Freespace: " & err.number & " Err Description: " & err.description
  932. Wscript.echo "In RunTlist(), Free space = " & DriveObject.FreeSpace
  933. Wscript.echo "In RunTlist(), MinFreeSpace = " & MinFreeSpace
  934. Wscript.echo ""
  935. End If
  936. If QuietMode = False Then
  937. objShell.popup "AutodumpPlus has detected that there is not enough free space on the following network share " & CrashDir & ". AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again.",,"AutodumpPlus",0
  938. Else
  939. objShell.LogEvent 1, "AutodumpPlus has detected that there is not enough free space on the following network share " & CrashDir & ". AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again."
  940. wscript.echo "AutodumpPlus has detected that there is not enough free space on the following network share " & CrashDir & ". AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again."
  941. End If
  942. DeleteDirectory(ShortCrashDir)
  943. wscript.quit 1
  944. End If
  945. Else
  946. If DEBUGGING = TRUE Then
  947. Wscript.echo "In RunTlist(), No_Free_Space_Checking = TRUE"
  948. Wscript.echo "In RunTlist(), Call to DriveObject.Freespace skipped!"
  949. Wscript.echo "In RunTlist(), Err number after calling objFileSystem.GetDrive: " & err.number & " Err Description: " & err.description
  950. Wscript.echo ""
  951. End If
  952. End If
  953. End If
  954. Else 'We are in hang mode
  955. If Left(ShortHangDir,2) <> "\\" Then 'We are in hang mode but not logging to a UNC path
  956. Set DriveObject = objFileSystem.GetDrive(Left(ShortHangDir,1))
  957. If No_Free_Space_Checking = False Then
  958. If DriveObject.FreeSpace < MinFreeSpace Then
  959. If DEBUGGING = TRUE Then
  960. Wscript.echo "In RunEcmdm(), No_Free_Space_Checking = FALSE"
  961. Wscript.echo "In RunTlist(), Err number after calling DriveObject.Freespace: " & err.number & " Err Description: " & err.description
  962. Wscript.echo "In RunTlist(), Free space = " & DriveObject.FreeSpace
  963. Wscript.echo "In RunTlist(), MinFreeSpace = " & MinFreeSpace
  964. Wscript.echo ""
  965. End If
  966. If QuietMode = False Then
  967. objShell.popup "AutodumpPlus has detected that there is not enough free space on the " & Left(ShortCrashDir,2) & " drive. AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again.",,"AutodumpPlus",0
  968. Else
  969. objShell.LogEvent 1, "AutodumpPlus has detected that there is not enough free space on the " & Left(ShortCrashDir,2) & " drive. AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again."
  970. wscript.echo "AutodumpPlus has detected that there is not enough free space on the " & Left(ShortCrashDir,2) & " drive. AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again."
  971. End If
  972. DeleteDirectory(ShortHangDir)
  973. wscript.quit 1
  974. End If
  975. Else
  976. If DEBUGGING = TRUE Then
  977. Wscript.echo "In RunTlist(), No_Free_Space_Checking = TRUE"
  978. Wscript.echo "In RunTlist(), Call to DriveObject.Freespace skipped!"
  979. Wscript.echo "In RunTlist(), Err number after calling objFileSystem.GetDrive: " & err.number & " Err Description: " & err.description
  980. Wscript.echo ""
  981. End If
  982. End If
  983. Else 'We are in hang mode but logging to a UNC path
  984. Path = ShortHangDir
  985. If DEBUGGING = TRUE Then
  986. Wscript.echo "Path = " & Path
  987. End If
  988. NewPath = Right(Path, Len(Path) - 2)
  989. If DEBUGGING = TRUE Then
  990. Wscript.echo "NewPath = " & NewPath
  991. End If
  992. PathArray = Split(NewPath, "\", -1)
  993. If DEBUGGING = TRUE Then
  994. Wscript.echo "ServerName = " & PathArray(0)
  995. End If
  996. ServerName = PathArray(0)
  997. If DEBUGGING = TRUE Then
  998. Wscript.echo "ShareName = " & PathArray(1)
  999. End If
  1000. ShareName = PathArray(1)
  1001. NewPath = "\\" & ServerName & "\" & ShareName
  1002. If DEBUGGING = TRUE Then
  1003. Wscript.echo "NewPath = " & NewPath
  1004. End If
  1005. Set DriveObject = objFileSystem.GetDrive(NewPath)
  1006. If No_Free_Space_Checking = False Then
  1007. If DriveObject.FreeSpace < MinFreeSpace Then
  1008. If DEBUGGING = TRUE Then
  1009. Wscript.echo "In RunEcmdm(), No_Free_Space_Checking = FALSE"
  1010. Wscript.echo "In RunTlist(), Err number after calling DriveObject.Freespace: " & err.number & " Err Description: " & err.description
  1011. Wscript.echo "In RunTlist(), Free space = " & DriveObject.FreeSpace
  1012. Wscript.echo "In RunTlist(), MinFreeSpace = " & MinFreeSpace
  1013. Wscript.echo ""
  1014. End If
  1015. If QuietMode = False Then
  1016. objShell.popup "AutodumpPlus has detected that there is not enough free space on the following network share " & HangDir & ". AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again.",,"AutodumpPlus",0
  1017. Else
  1018. objShell.LogEvent 1, "AutodumpPlus has detected that there is not enough free space on the following network share " & HangDir & ". AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again."
  1019. wscript.echo "AutodumpPlus has detected that there is not enough free space on the following network share " & HangDir & ". AutodumpPlus requires at least 10Mb of free space. Please free up some space on that drive and try running AutodumpPlus again."
  1020. End If
  1021. DeleteDirectory(ShortHangDir)
  1022. wscript.quit 1
  1023. End If
  1024. Else
  1025. If DEBUGGING = TRUE Then
  1026. Wscript.echo "In RunTlist(), No_Free_Space_Checking = TRUE"
  1027. Wscript.echo "In RunTlist(), Call to DriveObject.Freespace skipped!"
  1028. Wscript.echo "In RunTlist(), Err number after calling objFileSystem.GetDrive: " & err.number & " Err Description: " & err.description
  1029. Wscript.echo ""
  1030. End If
  1031. End If
  1032. End If
  1033. End If
  1034. If CrashMode = true Then
  1035. strShell = "cmd /c " & chr(34) & InstallDir & "\tlist.exe" & Chr(34) & " -k >" & ShortCrashDir & "\Process_List.txt"
  1036. 'Un-comment the line below in order to simulate the effects of a missing Process_List.txt file
  1037. 'strShell = "cmd /c " & chr(34) & InstallDir & "\tlist.exe -k"
  1038. If DEBUGGING = TRUE Then
  1039. wscript.echo "In RunTlist(), about to run tlist.exe, the strShell (emcmd command string) is: " & StrShell
  1040. Wscript.Echo ""
  1041. wscript.echo "-----------------------"
  1042. End If
  1043. objShell.Run strShell,MINIMIZE_NOACTIVATE,TRUE
  1044. Else
  1045. strShell = "cmd /c " & chr(34) & InstallDir & "\tlist.exe" & Chr(34) & " -k >" & ShortHangDir & "\Process_List.txt"
  1046. 'Un-comment the line below in order to simulate the effects of a missing Process_List.txt file
  1047. 'strShell = "cmd /c " & chr(34) & InstallDir & "\tlist.exe -k"
  1048. If DEBUGGING = TRUE Then
  1049. wscript.echo "In RunTlist(), about to run tlist.exe, the strShell (emcmd command string) is: " & StrShell
  1050. Wscript.Echo ""
  1051. wscript.echo "-----------------------"
  1052. End If
  1053. objShell.Run strShell,MINIMIZE_NOACTIVATE,TRUE
  1054. End If
  1055. End Sub
  1056. '---------------------------------------------------------------------------------------------
  1057. ' Function: CreateCDBScript
  1058. ' This function is used to create the CDB scripts used by the debugger.
  1059. ' If you wish to change the debug output for hangs, crashes, or quick mode, you can
  1060. ' add the necessary debugger commands so that they are placed in the CDB scripts the
  1061. ' next time AutodumpPlus is run.
  1062. '---------------------------------------------------------------------------------------------
  1063. Function CreateCDBScript(pid, packagename)
  1064. On Error Resume Next
  1065. Dim objFileSystem
  1066. Dim objTextFile
  1067. Dim strFile
  1068. Dim arResults
  1069. Dim objShell
  1070. Dim strShell
  1071. Dim versionFile
  1072. If CrashMode = True Then
  1073. strFile = CrashDir & "\CDBScripts"
  1074. CreateDirectory(strFile)
  1075. strFile = CrashDir & "\CDBScripts\" & "PID-" & pid & "__" & packagename & ".cfg"
  1076. Else
  1077. strFile = HangDir & "\CDBScripts"
  1078. CreateDirectory(strFile)
  1079. strFile = HangDir & "\CDBScripts\" & "PID-" & pid & "__" & packagename & ".cfg"
  1080. End If
  1081. If DEBUGGING = TRUE Then
  1082. Wscript.echo "---------------------------------------"
  1083. Wscript.echo "In the CreateCDBScript() function . . ."
  1084. Wscript.echo "In CreateCDBScript(), pid = " & pid
  1085. Wscript.echo "In CreateCDBScript(), packagename = " & packagename
  1086. Wscript.echo "In CreateCDBScript(), strFile (the name of the CDB script to create) = " & strFile
  1087. Wscript.echo ""
  1088. Wscript.echo "----------------------------------------"
  1089. End If
  1090. Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  1091. Set objShell = CreateObject("Wscript.Shell")
  1092. Set objTextFile = objFileSystem.CreateTextFile(strFile,True)
  1093. If CrashMode = True Then
  1094. If No_CrashMode_Log = FALSE Then
  1095. objTextFile.Writeline ".logopen " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & ".log"
  1096. Else
  1097. End If
  1098. objTextFile.Writeline ".echotimestamps"
  1099. objTextFile.Writeline ".sympath"
  1100. objTextFile.Writeline "*"
  1101. objTextFile.Writeline "* --------- AutodumpPlus " & VERSION & " was started at: -----------"
  1102. objTextFile.Writeline ".time"
  1103. objTextFile.Writeline "* ------------------------------------------------------"
  1104. objTextFile.Writeline "*"
  1105. objTextFile.Writeline "*"
  1106. objTextFile.Writeline "*"
  1107. objTextFile.Writeline "* --------- AutodumpPlus " & VERSION & " was run on server: --------"
  1108. objTextFile.Writeline "* Server name: " & ComputerName
  1109. objTextFile.Writeline "* ------------------------------------------------------"
  1110. objTextFile.Writeline "*"
  1111. objTextFile.Writeline "*"
  1112. objTextFile.Writeline "*"
  1113. objTextFile.Writeline "* ------ OS Version Information displayed below. -------"
  1114. objTextFile.Writeline "!version"
  1115. objTextFile.Writeline "* ------------------------------------------------------"
  1116. objTextFile.Writeline "*"
  1117. objTextFile.Writeline "*"
  1118. objTextFile.Writeline "*"
  1119. 'Setup the debug break exception handler
  1120. If PageHeapMode = False Then
  1121. If Full_Dump_on_CONTRL_C = TRUE Then
  1122. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- Listing all thread stacks: ---;~*kb250;.echo;.echo --- Listing loaded modules: ---;lmv;.echo;.echo --- Modules with matching symbols:;lml;.echo;.echo --- Listing all locks: ---;!locks;.echo;.echo ----------------------------------------------------------------------;.echo CTRL-C was pressed to stop debugging this process!;.echo ----------------------------------------------------------------------;.echo Exiting the debugger at:;.time;.echo;.dump /mfh /c CTRL-C_was_pressed_to_stop_the_debugger_while_running_in_crash_mode.__Full_memory_dump_from_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__CTRL-C__full.dmp;!elog_str AutodumpPlus detected that CTRL-C was pressed to stop debugging " & packagename & " and has created a full memory dump of the process in the " & CrashDir & " directory;q" & Chr(34) & " bpe"
  1123. Else
  1124. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- Listing all thread stacks: ---;~*kb250;.echo;.echo --- Listing loaded modules: ---;lmv;.echo;.echo --- Modules with matching symbols:;lml;.echo;.echo --- Listing all locks: ---;!locks;.echo;.echo ----------------------------------------------------------------------;.echo CTRL-C was pressed to stop debugging this process!;.echo ----------------------------------------------------------------------;.echo Exiting the debugger at:;.time;.echo;.dump -u /m /c CTRL-C_was_pressed_to_stop_the_debugger_while_running_in_crash_mode.__Mini_memory_dump_from_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__CTRL-C__mini.dmp;!elog_str AutodumpPlus detected that CTRL-C was pressed to stop debugging " & packagename & " and has created a mini-memory dump of the process in the " & CrashDir & " directory;q" & Chr(34) & " bpe"
  1125. End If
  1126. Else
  1127. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- Debug Break exception - Faulting stack below! ---;~#;kvn250;.echo -----------------------------------;.dump /mfh /c Debug_break_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__Debug_break_exception__full.dmp;!elog_str AutodumpPlus generated a Debug Break Exception dump while running in pageheap mode;.echo;.echo;.echo --- A debug break exception was encountered ---;.echo - AutodumpPlus will now detach the debugger;.echo - and end the debugging session.;.echo -----------------------------------" & Chr(34) & " bpe"
  1128. End If
  1129. 'Setup the invalid handle exception handler
  1130. If No_Dump_on_1st_Chance_Exception = True Then 'The user does not want a memory dump produced for a 1st chance exception.
  1131. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Invalid Handle exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Invalid Handle exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_invalid_handle_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_invalid_handle__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Invalid Handle exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " ch"
  1132. Else 'The user does want a memory dump produced for a 1st chance exception, now figure out which kind of memory dump (full or mini).
  1133. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1134. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Invalid Handle exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 1st_chance_invalid_handle_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__1st_chance_Invalid_Handle__full.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Invalid Handle exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_invalid_handle_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_invalid_handle__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Invalid Handle exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " ch"
  1135. Else
  1136. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Invalid Handle exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump -u /m /c 1st_chance_invalid_handle_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__1st_chance_Invalid_Handle__mini.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Invalid Handle exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_invalid_handle_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_invalid_handle__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Invalid Handle exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " ch"
  1137. End If
  1138. End If
  1139. 'Setup the illegal instruction exception handler
  1140. If No_Dump_on_1st_Chance_Exception = True Then 'The user does not want a memory dump produced for a 1st chance exception.
  1141. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Illegal Instruction exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Illegal Instruction exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Illegal_Instruction_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Illegal_Instruction__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Illegal Instruction exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " ii"
  1142. Else 'The user does want a memory dump produced for a 1st chance exception, now figure out which kind of memory dump (full or mini).
  1143. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1144. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Illegal Instruction exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 1st_chance_Illegal_Instruction_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__1st_chance_Illegal_Instruction__full.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Illegal Instruction exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Illegal_Instruction_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Illegal_Instruction__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Illegal Instruction exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " ii"
  1145. Else
  1146. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Illegal Instruction exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump -u /m /c 1st_chance_Illegal_Instruction_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__1st_chance_Illegal_Instruction__mini.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Illegal Instruction exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Illegal_Instruction_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Illegal_Instruction__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Illegal Instruction exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " ii"
  1147. End If
  1148. End If
  1149. 'Setup the Integer Divide by Zero exception handler
  1150. If No_Dump_on_1st_Chance_Exception = True Then 'The user does not want a memory dump produced for a 1st chance exception.
  1151. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Integer Divide by Zero exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Integer Divide by Zero exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Integer_Divide_by_Zero_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Integer_Divide_by_Zero__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Integer Divide by Zero exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " dz"
  1152. Else 'The user does want a memory dump produced for a 1st chance exception, now figure out which kind of memory dump (full or mini).
  1153. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1154. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Integer Divide by Zero exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 1st_chance_Integer_Divide_by_Zero_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__1st_chance_Integer_Divide_by_Zero__full.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Integer Divide by Zero exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Integer_Divide_by_Zero_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Integer_Divide_by_Zero__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Integer Divide by Zero exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " dz"
  1155. Else
  1156. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Integer Divide by Zero exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump -u /m /c 1st_chance_Integer_Divide_by_Zero_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__1st_chance_Integer_Divide_by_Zero__mini.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Integer Divide by Zero exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Integer_Divide_by_Zero_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Integer_Divide_by_Zero__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Integer Divide by Zero exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " dz"
  1157. End If
  1158. End If
  1159. 'Setup the Floating Point Divide by Zero exception handler
  1160. If No_Dump_on_1st_Chance_Exception = True Then 'The user does not want a memory dump produced for a 1st chance exception.
  1161. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Floating Point Divide by Zero exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Floating Point Divide by Zero exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Floating_Point_Divide_by_Zero_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Floating_Point_Divide_by_Zero__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Floating Point Divide by Zero exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " c000008e"
  1162. Else 'The user does want a memory dump produced for a 1st chance exception, now figure out which kind of memory dump (full or mini).
  1163. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1164. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Floating Point Divide by Zero exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 1st_chance_Floating_Point_Divide_by_Zero_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__1st_chance_Floating_Point_Divide_by_Zero__full.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Floating Point Divide by Zero exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Floating_Point_Divide_by_Zero_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Floating_Point_Divide_by_Zero__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Floating Point Divide by Zero exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " c000008e"
  1165. Else
  1166. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Floating Point Divide by Zero exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump -u /m /c 1st_chance_Floating_Point_Divide_by_Zero_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__1st_chance_Floating_Point_Divide_by_Zero__mini.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Floating Point Divide by Zero exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Floating_Point_Divide_by_Zero_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Floating_Point_Divide_by_Zero__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Floating Point Divide by Zero exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " c000008e"
  1167. End If
  1168. End If
  1169. 'Setup the Integer Overflow exception handler
  1170. If No_Dump_on_1st_Chance_Exception = True Then 'The user does not want a memory dump produced for a 1st chance exception.
  1171. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Integer Overflow exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Integer Overflow exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Integer_Overflow_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Integer_Overflow__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Integer Overflow exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " dz"
  1172. Else 'The user does want a memory dump produced for a 1st chance exception, now figure out which kind of memory dump (full or mini).
  1173. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1174. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Integer Overflow exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 1st_chance_Integer_Overflow_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__1st_chance_Integer_Overflow__full.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Integer Overflow exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Integer_Overflow_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Integer_Overflow__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Integer Overflow exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " dz"
  1175. Else
  1176. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Integer Overflow exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump -u /m /c 1st_chance_Integer_Overflow_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__1st_chance_Integer_Overflow__mini.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Integer Overflow exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Integer_Overflow_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Integer_Overflow__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Integer Overflow exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " dz"
  1177. End If
  1178. End If
  1179. 'Setup the Invalid Lock Sequence exception handler
  1180. If No_Dump_on_1st_Chance_Exception = True Then 'The user does not want a memory dump produced for a 1st chance exception.
  1181. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Invalid Lock Sequence exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Invalid Lock Sequence exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Invalid_Lock_Sequence_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Invalid_Lock_Sequence__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Invalid Lock Sequence exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " lsq"
  1182. Else 'The user does want a memory dump produced for a 1st chance exception, now figure out which kind of memory dump (full or mini).
  1183. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1184. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Invalid Lock Sequence exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 1st_chance_Invalid_Lock_Sequence_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__1st_chance_Invalid_Lock_Sequence__full.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Invalid Lock Sequence exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Invalid_Lock_Sequence_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Invalid_Lock_Sequence__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Invalid Lock Sequence exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " lsq"
  1185. Else
  1186. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Invalid Lock Sequence exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump -u /m /c 1st_chance_Invalid_Lock_Sequence_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__1st_chance_Invalid_Lock_Sequence__mini.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Invalid Lock Sequence exception - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_Invalid_Lock_Sequence_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_Invalid_Lock_Sequence__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Invalid Lock Sequence exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " lsq"
  1187. End If
  1188. End If
  1189. 'Setup the Acces Violation exception handler
  1190. If No_Dump_on_1st_Chance_Exception = True Then 'The user does not want a memory dump produced for a 1st chance exception.
  1191. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Access Violation - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Acess Violation - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_access_violation_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_access_violation__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Access Violation exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " av"
  1192. Else 'The user does want a memory dump produced for a 1st chance exception, now figure out which kind of memory dump (full or mini).
  1193. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1194. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Access Violation - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 1st_chance_access_violation_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__1st_chance_access_violation__full.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Acess Violation - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_access_violation_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_access_violation__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Access Violation exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " av"
  1195. Else
  1196. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Access Violation - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump -u /m /c 1st_chance_access_violation_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__1st_chance_access_violation__mini.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance Acess Violation - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_access_violation_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_access_violation__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Access Violation exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " av"
  1197. End If
  1198. End If
  1199. 'Setup the Stack Overflow exception handler
  1200. If No_Dump_on_1st_Chance_Exception = True Then 'The user does not want a memory dump produced for a 1st chance exception.
  1201. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Stack Overflow - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance stack overflow - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_stack_overflow_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance__stack_overflow__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Stack Overflow exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " sov"
  1202. Else 'The user does want a memory dump produced for a 1st chance exception, now figure out which kind of memory dump (full or mini).
  1203. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1204. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Stack Overflow - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 1st_chance_stack_overflow_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__1st_chance_stack_overflow__full.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance stack overflow - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_stack_overflow_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance__stack_overflow__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Stack Overflow exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " sov"
  1205. Else
  1206. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Stack Overflow - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump -u /m /c 1st_chance_stack_overflow_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__1st_chance_stack_overflow__mini.dmp;.echo;.echo;gn" & Chr(34) & " -c2 " & Chr(34) & ".echo --- 2nd chance stack overflow - Faulting stack below ---;~#;kvn250;.dump /mfh /c 2nd_chance_stack_overflow_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance__stack_overflow__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Stack Overflow exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " sov"
  1207. End If
  1208. End If
  1209. 'Setup the C++ EH exception handler
  1210. 'By default C++ EH exceptions are only logged to the log file (if logging is enabled) and there is no memory dump produced to minimize the impact on performance.
  1211. If Dump_on_EH_Exceptions = TRUE AND No_Dump_on_1st_Chance_Exception = FALSE Then 'Check to see whether we should produce a mini dump or a full memory dump
  1212. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1213. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance C++ EH exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 1st_chance_C++_EH_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__1st_chance_C++_EH_exception__full.dmp;.echo;.echo;gn" & Chr(34) & "-c2 " & Chr(34) & ".echo --- 2nd chance C++ EH exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 2nd_chance_C++_EH_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_C++_EH__full.dmp;!elog_str AutodumpPlus detected a 2nd chance EH exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " eh"
  1214. Else
  1215. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance C++ EH exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump -u /m /c 1st_chance_C++_EH_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__1st_chance_C++_EH_exception__mini.dmp;.echo;.echo;gn" & Chr(34) & "-c2 " & Chr(34) & ".echo --- 2nd chance C++ EH exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 2nd_chance_C++_EH_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_C++_EH__full.dmp;!elog_str AutodumpPlus detected a 2nd chance EH exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " eh"
  1216. End If
  1217. Else 'By default, ADPlus does not produce a memory dump on 1st chance EH exceptions, it just logs the stack and continues without handling the exception (gn).
  1218. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance C++ EH exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.echo;.echo;gn" & Chr(34) & "-c2 " & Chr(34) & ".echo --- 2nd chance C++ EH exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 2nd_chance_C++_EH_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_C++_EH__full.dmp;q" & Chr(34) & " eh"
  1219. End If
  1220. 'Setup the unknown exception handler
  1221. 'By default unknown exceptions are only logged to the log file (if logging is enabled) and there is no memory dump produced to minimize the impact on performance.
  1222. If Dump_on_Unknown_Exceptions = TRUE AND No_Dump_on_1st_Chance_Exception = FALSE Then 'Check to see whether we should produce a mini dump or a full memory dump
  1223. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1224. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Unknown exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 1st_chance_unknown_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__1st_chance_unknown_exception__full.dmp;.echo;.echo;gn" & Chr(34) & "-c2 " & Chr(34) & ".echo --- 2nd chance unknown exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 2nd_chance_Unknown_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_unknown_exception__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Unknown exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " *"
  1225. Else
  1226. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Unknown exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump -u /m /c 1st_chance_unknown_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__1st_chance_unknown_exception__mini.dmp;.echo;.echo;gn" & Chr(34) & "-c2 " & Chr(34) & ".echo --- 2nd chance unknown exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 2nd_chance_Unknown_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_unknown_exception__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Unknown exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " *"
  1227. End If
  1228. Else 'By default, ADPlus does not produce a memory dump on 1st chance unknown exceptions, it just logs the stack and continues without handling the exception (gn).
  1229. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- 1st chance Unknown exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.echo;.echo;gn" & Chr(34) & "-c2 " & Chr(34) & ".echo --- 2nd chance unknown exception - Faulting stack below ----;~#;kvn250;.echo -----------------------------------;.dump /mfh /c 2nd_chance_Unknown_exception_in_" & packagename & "_running_on_" & ComputerName & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__2nd_chance_unknown_exception__full.dmp;!elog_str AutodumpPlus detected a 2nd chance Unknown exception in process " & packagename & " and has created a full memory dump of the process at the time of the crash in the " & CrashDir & " directory;q" & Chr(34) & " *"
  1230. End If
  1231. 'Setup the DLL Load exception handler
  1232. If Dump_Stack_on_DLL_Load = TRUE Then
  1233. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- A DLL was loaded - Stack back trace below ----;~#;kvn250;.echo -----------------------------------;.echo;gn" & Chr(34) & " ld"
  1234. End If
  1235. 'Setup the DLL UnLoad exception handler
  1236. If Dump_Stack_on_DLL_UnLoad = TRUE Then
  1237. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo --- A DLL was un-loaded - Stack back trace below ----;~#;kvn250;.echo -----------------------------------;.echo;gn" & Chr(34) & " ud"
  1238. End If
  1239. 'Setup the end process exception handler
  1240. If Create_Full_Dump_on_1st_Chance_Exception = TRUE Then
  1241. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo;.echo ----------------------------------------------------------------------;.echo This process is shutting down!;.echo;.echo This can happen for the following reasons:;.echo 1.) Someone killed the process with Task Manager or the kill command.;.echo;.echo 2.) If this process is an MTS or COM+ server package, it could be;.echo* exiting because an MTS/COM+ server package idle limit was reached.;.echo;.echo 3.) If this process is an MTS or COM+ server package,;.echo* someone may have shutdown the package via the MTS Explorer or;.echo* Component Services MMC snap-in.;.echo;.echo 4.) If this process is an MTS or COM+ server package,;.echo* MTS or COM+ could be shutting down the process because an internal;.echo* error was detected in the process (MTS/COM+ fail fast condition).;.echo ----------------------------------------------------------------------;.echo;.echo --- Listing all remaining threads at time of shutdown ----;~*kv250;.echo ----------------------------------------------------------------------;.echo;.echo The process was shut down at:;.time;.echo;.echo;.dump /mfh /c The_following_process_" & packagename & "_running_on_" & ComputerName & "_was_shutdown_or_killed" & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__Process_was_shutdown__full.dmp;!elog_str AutodumpPlus detected that the following process " & packagename & " is shutting down or was killed and has created a full memory dump of the process at the time of the shutdown in the " & CrashDir & " directory;" & Chr(34) & " epr"
  1242. Else
  1243. objTextFile.Writeline "sxe -c " & Chr(34) & ".echo;.echo ----------------------------------------------------------------------;.echo This process is shutting down!;.echo;.echo This can happen for the following reasons:;.echo 1.) Someone killed the process with Task Manager or the kill command.;.echo;.echo 2.) If this process is an MTS or COM+ server package, it could be;.echo* exiting because an MTS/COM+ server package idle limit was reached.;.echo;.echo 3.) If this process is an MTS or COM+ server package,;.echo* someone may have shutdown the package via the MTS Explorer or;.echo* Component Services MMC snap-in.;.echo;.echo 4.) If this process is an MTS or COM+ server package,;.echo* MTS or COM+ could be shutting down the process because an internal;.echo* error was detected in the process (MTS/COM+ fail fast condition).;.echo ----------------------------------------------------------------------;.echo;.echo --- Listing all remaining threads at time of shutdown ----;~*kv250;.echo ----------------------------------------------------------------------;.echo;.echo The process was shut down at:;.time;.echo;.echo;.dump -u /m /c The_following_process_" & packagename & "_running_on_" & ComputerName & "_was_shutdown_or_killed" & " " & ShortCrashDir & "\" & "PID-" & pid & "__" & packagename & "__Process_was_shutdown__mini.dmp;!elog_str AutodumpPlus detected that the following process " & packagename & " is shutting down or was killed and has created a mini-memory dump of the process at the time of the shutdown in the " & CrashDir & " directory;" & Chr(34) & " epr"
  1244. End If
  1245. objTextFile.Writeline "*"
  1246. objTextFile.Writeline "* AutodumpPlus is monitoring: " & packagename
  1247. objTextFile.Writeline "* for most types of 1st chance and 2nd chance exceptions."
  1248. objTextFile.Writeline "*"
  1249. objTextFile.Writeline "* When a first chance exception is encountered, the process is paused"
  1250. objTextFile.Writeline "* while the faulting thread's stack is logged to a .log file and a"
  1251. objTextFile.Writeline "* mini-memory dump is created. The process will then resume."
  1252. objTextFile.Writeline "*"
  1253. objTextFile.Writeline "* If a second chance exception is encountered, the process is paused"
  1254. objTextFile.Writeline "* while the faulting thread's stack is logged to a .log file and a"
  1255. objTextFile.Writeline "* full memory dump is created. The debugger then quits and the process"
  1256. objTextFile.Writeline "* may need to be re-started."
  1257. objTextFile.Writeline "*"
  1258. objTextFile.Writeline "* C++ EH and Unknown exceptions, by deafult, will not produce memory"
  1259. objTextFile.Writeline "* dumps on 1st chance exceptions (see Q286350 for more info)."
  1260. objTextFile.Writeline "*"
  1261. objTextFile.Writeline "* If this process hangs, or to stop debugging this process please press"
  1262. objTextFile.Writeline "* CTRL-C in this window to produce a memory dump and to stop debugging."
  1263. objTextFile.Writeline "*"
  1264. objTextFile.Writeline "* NOTE: To stop debugging this process, do NOT close this window by"
  1265. objTextFile.Writeline "* pressing the X button at the top-right corner, please press CTRL-C to"
  1266. objTextFile.Writeline "* stop debugging. After pressing CTRL-C in this window, you will need to"
  1267. objTextFile.Writeline "* re-start this process. If you are monitoring IIS 5.0, IIS 5.0 will be"
  1268. objTextFile.Writeline "* re-started automatically by the Windows 2000 Service Control Manager."
  1269. 'Setup the DLL Load / Unload information
  1270. If (Dump_Stack_on_DLL_Load = TRUE or Dump_Stack_on_DLL_UnLoad) Then
  1271. objTextFile.Writeline "*"
  1272. objTextFile.Writeline "*"
  1273. objTextFile.Writeline "* -------------------- Listing loaded modules -------------------------"
  1274. objTextFile.Writeline "lmv"
  1275. objTextFile.Writeline "* ---------------------------------------------------------------------"
  1276. End If
  1277. objTextFile.Writeline "g"
  1278. objTextFile.Writeline "*"
  1279. objTextFile.Writeline "*"
  1280. objTextFile.Writeline "*"
  1281. objTextFile.Writeline "* -------- AutodumpPlus " & VERSION & " finished running at: --------"
  1282. objTextFile.Writeline ".time"
  1283. objTextFile.Writeline "* -------------------------------------------------------"
  1284. 'If the -notify switch was used then send a message to the computer or user specified on the command line
  1285. 'Note on NT 4.0 LocalUserName will be blank because the Volatile Environment variable can only be quired on Windows 2000 to get the
  1286. 'local username. So we must send the message from the NotifyTarget on NT 4.0, instead of the locally logged on user.
  1287. If NotifyAdmin = True Then
  1288. If OSVer = "4.0" Then
  1289. objTextFile.Writeline "!net_send " & ComputerName & " " & NotifyTarget & " " & NotifyTarget & " AutodumpPlus has finished running in crash mode on " & ComputerName & " for the following process: " & packagename & ". This could indicate that a crash has occurred, or that the debugging session was ended manually (CTRL-C was pressed to stop debugging). Please check the application event log on " & ComputerName & " for more information."
  1290. Else
  1291. objTextFile.Writeline "!net_send " & ComputerName & " " & NotifyTarget & " " & LocalUsername & " AutodumpPlus has finished running in crash mode on " & ComputerName & " for the following process: " & packagename & ". This could indicate that a crash has occurred, or that the debugging session was ended manually (CTRL-C was pressed to stop debugging). Please check the application event log on " & ComputerName & " for more information."
  1292. End If
  1293. End If
  1294. objTextFile.Writeline "q"
  1295. ElseIf QuickMode = True Then
  1296. objTextFile.Writeline ".logopen " & ShortHangDir & "\" & "PID-" & pid & "__" & packagename & "__" & DateTimeStamp & ".log"
  1297. objTextFile.Writeline "*.reload /s"
  1298. objTextFile.Writeline ".sympath"
  1299. objTextFile.Writeline "*"
  1300. objTextFile.Writeline "* --------- AutodumpPlus " & VERSION & " was started at: -----------"
  1301. objTextFile.Writeline ".time"
  1302. objTextFile.Writeline "* ------------------------------------------------------"
  1303. objTextFile.Writeline "*"
  1304. objTextFile.Writeline "*"
  1305. objTextFile.Writeline "*"
  1306. objTextFile.Writeline "* --------- OS Version Information: ---------------------"
  1307. objTextFile.Writeline "!version"
  1308. objTextFile.Writeline "* ------------------------------------------------------"
  1309. objTextFile.Writeline "*"
  1310. objTextFile.Writeline "*"
  1311. objTextFile.Writeline "*"
  1312. objTextFile.Writeline "* --------- AutodumpPlus " & VERSION & " was run on server: --------"
  1313. objTextFile.Writeline "* Server name: " & ComputerName
  1314. objTextFile.Writeline "* ------------------------------------------------------"
  1315. objTextFile.Writeline "*"
  1316. objTextFile.Writeline "*"
  1317. objTextFile.Writeline "*"
  1318. objTextFile.Writeline "* --------- Heap information: --------------------------"
  1319. objTextFile.Writeline "!heap 0 -k"
  1320. objTextFile.Writeline "* ------------------------------------------------------"
  1321. objTextFile.Writeline "*"
  1322. objTextFile.Writeline "*"
  1323. objTextFile.Writeline "*"
  1324. objTextFile.Writeline "* --------- Handle information: ------------------------"
  1325. objTextFile.Writeline "!handle 0 0"
  1326. objTextFile.Writeline "* ------------------------------------------------------"
  1327. objTextFile.Writeline "*"
  1328. objTextFile.Writeline "*"
  1329. objTextFile.Writeline "*"
  1330. objTextFile.Writeline "* -------- Thread stack backtrace information: ---------"
  1331. objTextFile.Writeline "~*kb250"
  1332. objTextFile.Writeline "* ------------------------------------------------------"
  1333. objTextFile.Writeline "*"
  1334. objTextFile.Writeline "*"
  1335. objTextFile.Writeline "*"
  1336. objTextFile.Writeline "* -------- Loaded modules: -----------------------------"
  1337. objTextFile.Writeline "lmv"
  1338. objTextFile.Writeline "* ------------------------------------------------------"
  1339. objTextFile.Writeline "*"
  1340. objTextFile.Writeline "*"
  1341. objTextFile.Writeline "*"
  1342. objTextFile.Writeline "* -------- Loaded modules with matching symbols: -------"
  1343. objTextFile.Writeline "lml"
  1344. objTextFile.Writeline "* ------------------------------------------------------"
  1345. objTextFile.Writeline "*"
  1346. objTextFile.Writeline "*"
  1347. objTextFile.Writeline "*"
  1348. objTextFile.Writeline "* -------- DLL Information: ----------------------------"
  1349. objTextFile.Writeline "!dlls"
  1350. objTextFile.Writeline "* ------------------------------------------------------"
  1351. objTextFile.Writeline "*"
  1352. objTextFile.Writeline "*"
  1353. objTextFile.Writeline "*"
  1354. objTextFile.Writeline "* -------- Critical section information: ---------------"
  1355. objTextFile.Writeline "!locks"
  1356. objTextFile.Writeline "* ------------------------------------------------------"
  1357. objTextFile.Writeline "*"
  1358. objTextFile.Writeline "*"
  1359. objTextFile.Writeline "*"
  1360. objTextFile.Writeline "* -------- Time & Uptime Statistics: -------------------"
  1361. objTextFile.Writeline "* Time & Uptime Statistics:"
  1362. objTextFile.Writeline ".time"
  1363. objTextFile.Writeline "* ------------------------------------------------------"
  1364. objTextFile.Writeline "*"
  1365. objTextFile.Writeline "*"
  1366. objTextFile.Writeline "*"
  1367. objTextFile.Writeline ".dump -u /m /c " & Chr(34) & "Mini memory dump for " & packagename & " created by AutodumpPlus Version " & VERSION & " running on " & ComputerName & " in quick/hang mode!" & Chr(34) & " " & ShortHangDir & "\PID-" & pid & "__" & packagename & "__mini.dmp"
  1368. objTextFile.Writeline ".logclose"
  1369. objTextFile.Writeline "q"
  1370. Else
  1371. objTextFile.Writeline ".dump /mfh /c " & Chr(34) & "Full memory dump for " & packagename & " created by AutodumpPlus Version " & VERSION & " running on " & ComputerName & " in normal/hang mode!" & Chr(34) & " " & ShortHangDir & "\PID-" & pid & "__" & packagename & "__" & DateTimeStamp & "__full.dmp"
  1372. objTextFile.Writeline "q"
  1373. End If
  1374. objTextFile.Close
  1375. Set objFileSystem = nothing
  1376. Set objTextFile = nothing
  1377. Set objShell = nothing
  1378. CreateCDBScript = strFile
  1379. End Function
  1380. '---------------------------------------------------------------------------------------------
  1381. ' Function: DumpIIS
  1382. ' This is a rather large function and it is the main function used to dump
  1383. ' all of the MTS / COM+ processes when running in either quick or normal mode.
  1384. ' Generic processes (those specified by the -p or -pn switch) are dumped using the
  1385. ' DumpAnyProc() function.
  1386. '---------------------------------------------------------------------------------------------
  1387. Sub DumpIIS(strFile,OSVersion)
  1388. On Error Resume Next
  1389. Dim objFileSystem
  1390. Dim oFS2
  1391. Dim objTextFile
  1392. Dim str
  1393. Dim arResults
  1394. Dim objShell
  1395. Dim strShell
  1396. Dim versionFile
  1397. Dim TempCounter
  1398. Dim i
  1399. Dim TotalPackageCount
  1400. Dim WheresTheSpace
  1401. If DEBUGGING = TRUE Then
  1402. Wscript.echo ""
  1403. Wscript.echo "-----------------------------------"
  1404. Wscript.echo "In the DumpIIS() function . . ."
  1405. Wscript.echo "In DumpIIS(), strFile = " & strFile
  1406. Wscript.echo "In DumpIIS(), OSVersion = " & OSVersion
  1407. Wscript.echo ""
  1408. End If
  1409. i = 0
  1410. Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  1411. Set oFS2 = CreateObject("Scripting.FileSystemObject")
  1412. Set objShell = CreateObject("Wscript.Shell")
  1413. 'Per the scripting team's advice, sleep for .5 second prior to calling this function.
  1414. Wscript.sleep 500
  1415. If CrashMode = true Then
  1416. If DEBUGGING = TRUE Then
  1417. Wscript.echo "In DumpIIS(), The Process_List.txt file should be located here: " & CrashDir & "\Process_List.txt"
  1418. Wscript.echo ""
  1419. End If
  1420. While not objFileSystem.FileExists(CrashDir & "\Process_List.txt")
  1421. Wscript.sleep 1000
  1422. If DEBUGGING = TRUE Then
  1423. wscript.echo "In DumpIIS(), The Process_List.txt file has not been created yet, sleeping for 1 second and trying again."
  1424. wscript.echo ""
  1425. End If
  1426. i = i +1
  1427. If i = 10 Then
  1428. If DEBUGGING = TRUE Then
  1429. wscript.echo "In DumpIIS(), Could not find the Process_List.txt file in the folder: " & CrashDir
  1430. wscript.echo "In DumpIIS(), Exiting AutodumpPlus now."
  1431. wscript.echo ""
  1432. End If
  1433. If QuietMode = False Then
  1434. objShell.PopUp "The file Process_List.txt could not be found in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again.",,"AutodumpPlus",0
  1435. Else
  1436. Wscript.echo "The file Process_List.txt could not be found in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1437. objShell.LogEvent 1, "The file Process_List.txt could not be found in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1438. ErrorsDuringRuntime = True
  1439. End If
  1440. If HangMode = True Then
  1441. DeleteDirectory(HangDir)
  1442. Else
  1443. DeleteDirectory(CrashDir)
  1444. End If
  1445. wscript.quit 1
  1446. End If
  1447. Wend
  1448. Else 'Running in Hang or Quick modes . . .
  1449. If DEBUGGING = TRUE Then
  1450. Wscript.echo "In DumpIIS(), The Process_List.txt file should be located here: " & HangDir & "\Process_List.txt"
  1451. End If
  1452. While not objFileSystem.FileExists(HangDir & "\Process_List.txt")
  1453. Wscript.sleep 1000
  1454. If DEBUGGING = TRUE Then
  1455. wscript.echo "In DumpIIS(), The Process_List.txt file has not been created yet, sleeping for 1 second and trying again."
  1456. wscript.echo ""
  1457. End If
  1458. i = i +1
  1459. If i = 10 Then
  1460. If DEBUGGING = TRUE Then
  1461. wscript.echo "In DumpIIS(), Could not find the Process_List.txt file in the folder: " & HangDir
  1462. wscript.echo "In DumpIIS(), Exiting AutodumpPlus now."
  1463. wscript.echo ""
  1464. End If
  1465. If QuietMode = False Then
  1466. objShell.PopUp "The file Process_List.txt could not be found in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again.",,"AutodumpPlus",0
  1467. Else
  1468. Wscript.echo "The file Process_List.txt could not be found in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1469. objShell.LogEvent 1, "The file Process_List.txt could not be found in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1470. ErrorsDuringRuntime = True
  1471. End If
  1472. If HangMode = True Then
  1473. DeleteDirectory(HangDir)
  1474. Else
  1475. DeleteDirectory(CrashDir)
  1476. End If
  1477. wscript.quit 1
  1478. End If
  1479. Wend
  1480. End If
  1481. If HangMode = True Then
  1482. Set objTextFile = objFileSystem.OpenTextFile(HangDir & "\Process_List.txt",ForReading,TristateUseDefault)
  1483. Else
  1484. Set objTextFile = objFileSystem.OpenTextFile(CrashDir & "\Process_List.txt",ForReading,TristateUseDefault)
  1485. End If
  1486. i = 0
  1487. While objTextFile.AtEndOfStream
  1488. 'Close the text file to let it finish writing and to get a new copy . . .
  1489. objTextFile.Close
  1490. wscript.sleep 1000
  1491. If DEBUGGING = TRUE Then
  1492. wscript.echo "In DumpIIS(), Waiting for Process_List.txt to finish writing (sleeping 1 second). . . "
  1493. wscript.echo ""
  1494. End If
  1495. i = i +1
  1496. If i = 10 Then
  1497. If HangMode = True Then
  1498. If DEBUGGING = TRUE Then
  1499. wscript.echo "In DumpIIS(), Process_List.txt was never closed (finished writing) in the folder: " & HangDir
  1500. wscript.echo "In DumpIIS(), Exiting AutodumpPlus now."
  1501. wscript.echo ""
  1502. End If
  1503. If QuietMode = False Then
  1504. objShell.PopUp "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again.",,"AutodumpPlus",0
  1505. Else
  1506. Wscript.echo "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1507. objShell.LogEvent 1, "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1508. ErrorsDuringRuntime = True
  1509. End If
  1510. DeleteDirectory(HangDir)
  1511. wscript.quit 1
  1512. Else
  1513. If DEBUGGING = TRUE Then
  1514. wscript.echo "In DumpIIS(), Process_List.txt was never closed (finished writing) in the folder: " & CrashDir
  1515. wscript.echo "In DumpIIS(), Exiting AutodumpPlus now."
  1516. wscript.echo ""
  1517. End If
  1518. If QuietMode = False Then
  1519. objShell.PopUp "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again.",,"AutodumpPlus",0
  1520. Else
  1521. Wscript.echo "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1522. objShell.LogEvent 1, "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1523. ErrorsDuringRuntime = True
  1524. End If
  1525. DeleteDirectory(CrashDir)
  1526. wscript.quit 1
  1527. End If
  1528. End If
  1529. 'Open the text file again before looping . . .
  1530. If HangMode = True Then
  1531. Set objTextFile = objFileSystem.OpenTextFile(HangDir & "\Process_List.txt",ForReading,TristateUseDefault)
  1532. Else
  1533. Set objTextFile = objFileSystem.OpenTextFile(CrashDir & "\Process_List.txt",ForReading,TristateUseDefault)
  1534. End If
  1535. Wend
  1536. While not objTextFile.AtEndofStream
  1537. str = objTextFile.ReadLine
  1538. Str = LTrim(Str)
  1539. arResults= split(Str," ",-1,1)
  1540. arResults(1)=trim(arResults(1))
  1541. arResults(1)=Replace(arResults(1),"/",",")
  1542. arResults(1)=Replace(arResults(1),"\",",")
  1543. arResults(1)=Replace(arResults(1),"<","(")
  1544. arResults(1)=Replace(arResults(1),">",")")
  1545. arResults(1)=Replace(arResults(1),":","")
  1546. arResults(1)=Replace(arResults(1),"*","")
  1547. arResults(1)=Replace(arResults(1),"?","")
  1548. arResults(1)=Replace(arResults(1),"|","")
  1549. If UCase(arResults(1)) = "INETINFO.EXE" Then
  1550. IISPid = Trim(arResults(0))
  1551. End If
  1552. Wend
  1553. objTextFile.Close
  1554. If DEBUGGING = True Then
  1555. wscript.echo ""
  1556. wscript.echo "In DumpIIS(), strFile = " & strFile
  1557. wscript.echo "In DumpIIS(), about to open strFile for reading . . ."
  1558. End If
  1559. 'Open the Process_List.txt and count how many packages / applications are running.
  1560. 'This code was updated to limit ADPlus to only attaching to up to MAX_APPLICATIONS_TO_DEBUG
  1561. 'NOTE: If there are more than MAX_APPLICATIONS_TO_DEBUG applications running ADPlus will
  1562. 'display an error and quit.
  1563. Set objTextFile = objFileSystem.OpenTextFile(strFile,ForReading,TristateUseDefault)
  1564. While not objTextFile.AtEndofStream
  1565. str = objTextFile.ReadLine
  1566. Str = LTrim(Str)
  1567. If InStr(Str, "Mts:") Then
  1568. arResults= split(Str,":",-1,1)
  1569. arResults(1)=trim(arResults(1))
  1570. arResults(1)=Replace(arResults(1),"/",",")
  1571. arResults(1)=Replace(arResults(1),"\",",")
  1572. arResults(1)=Replace(arResults(1),"<","(")
  1573. arResults(1)=Replace(arResults(1),">",")")
  1574. arResults(1)=Replace(arResults(1),":","")
  1575. arResults(1)=Replace(arResults(1),"*","")
  1576. arResults(1)=Replace(arResults(1),"?","")
  1577. arResults(1)=Replace(arResults(1),"|","")
  1578. arResults(0)=LTrim(arResults(0))
  1579. WheresTheSpace = InStr(arResults(0)," ")
  1580. arResults(0)= Left(arResults(0),(WheresTheSpace-1))
  1581. TotalPackageCount = TotalPackageCount+1
  1582. End if
  1583. Wend
  1584. 'Close the text file.
  1585. objTextFile.Close
  1586. If DEBUGGING = TRUE Then
  1587. Wscript.echo "In DumpIIS() TotalPackageCount = " & TotalPackageCount
  1588. End If
  1589. 'This is the logic to display the error message if too many packages / applications are running when
  1590. 'used with the -IIS switch.
  1591. If TotalPackageCount > MAX_APPLICATIONS_TO_DEBUG Then
  1592. If OSVersion = "4.0" Then
  1593. If QuietMode = False Then
  1594. objShell.PopUp "AutodumpPlus has determined that there are currently " & TotalpackageCount & " MTS server packages running. AutodumpPlus when used with the '-IIS' switch, by default, will only monitor up to " & MAX_APPLICATIONS_TO_DEBUG & " MTS server packages because of the impact on system resources.",,"AutodumpPlus",0
  1595. Else
  1596. Wscript.echo "AutodumpPlus has determined that there are currently " & TotalpackageCount & " MTS server packages running. AutodumpPlus when used with the '-IIS' switch, by default, will only monitor up to " & MAX_APPLICATIONS_TO_DEBUG & " MTS server packages because of the impact on system resources."
  1597. objShell.LogEvent 1, "AutodumpPlus has determined that there are currently " & TotalpackageCount & " MTS server packages running. AutodumpPlus when used with the '-IIS' switch, by default, will only monitor up to " & MAX_APPLICATIONS_TO_DEBUG & " MTS server packages because of the impact on system resources."
  1598. ErrorsDuringRuntime = True
  1599. End If
  1600. 'Delete the crash or hang mode directory since we are quitting.
  1601. If HangMode = True Then
  1602. Call DeleteDirectory(HangDir)
  1603. Else
  1604. Call DeleteDirectory(CrashDir)
  1605. End If
  1606. wscript.quit 1
  1607. Else
  1608. If QuietMode = False Then
  1609. objShell.PopUp "AutodumpPlus has determined that there are currently " & TotalpackageCount & " COM+ server applications running. AutodumpPlus when used with the '-IIS' switch, by default, will only monitor up to " & MAX_APPLICATIONS_TO_DEBUG & " COM+ server applications because of the impact on system resources.",,"AutodumpPlus",0
  1610. Else
  1611. Wscript.echo "AutodumpPlus has determined that there are currently " & TotalpackageCount & " COM+ server applications running. AutodumpPlus when used with the '-IIS' switch, by default, will only monitor up to " & MAX_APPLICATIONS_TO_DEBUG & " COM+ server applications because of the impact on system resources."
  1612. objShell.LogEvent 1, "AutodumpPlus has determined that there are currently " & TotalpackageCount & " COM+ server applications running. AutodumpPlus when used with the '-IIS' switch, by default, will only monitor up to " & MAX_APPLICATIONS_TO_DEBUG & " COM+ server applications because of the impact on system resources."
  1613. ErrorsDuringRuntime = True
  1614. End If
  1615. 'Delete the crash or hang mode directory since we are quitting.
  1616. If HangMode = True Then
  1617. Call DeleteDirectory(HangDir)
  1618. Else
  1619. Call DeleteDirectory(CrashDir)
  1620. End If
  1621. wscript.quit 1
  1622. End If
  1623. End If
  1624. 'Open the Process_List.txt
  1625. Set objTextFile = objFileSystem.OpenTextFile(strFile,ForReading,TristateUseDefault)
  1626. if not objTextFile.AtEndOfStream Then
  1627. If DEBUGGING = TRUE Then
  1628. wscript.echo "In DumpIIS(), Succesffully opened the file " & strFile & ". tlist.exe -k appears to have run."
  1629. wscript.echo ""
  1630. End If
  1631. If DEBUGGING = TRUE Then
  1632. wscript.echo "In DumpIIS(), The first line of " & strFile & " contains: " & Str
  1633. wscript.echo ""
  1634. End If
  1635. If HangMode = true and QuickMode = true Then
  1636. Wscript.Echo "The '-quick' switch was used, AutodumpPlus is running in 'quick hang' mode."
  1637. ElseIf HangMode = true Then
  1638. Wscript.echo "The '-hang' switch was used, Autdoump is running in 'hang' mode."
  1639. End If
  1640. If CrashMode = true Then
  1641. Wscript.Echo "The '-crash' switch was used, AutodumpPlus is running in 'crash' mode."
  1642. End If
  1643. If PageHeapMode = true Then
  1644. Wscript.Echo "The '-pageheap' switch was used, AutodumpPlus is running in 'pageheap' mode."
  1645. End If
  1646. If QuietMode = true Then
  1647. Wscript.Echo "The '-quiet' switch was used, AutodumpPlus will not display any"
  1648. Wscript.Echo "modal dialog boxes."
  1649. End If
  1650. If OSwitchUsed = true Then
  1651. Wscript.Echo "The '-o' switch was used. AutodumpPlus will place all files in"
  1652. Wscript.echo "the following directory: " & OutputDir
  1653. End If
  1654. If NotifyAdmin = true Then
  1655. Wscript.Echo "The '-notify' switch was used. AutodumpPlus will send notification to"
  1656. Wscript.echo "the following computer or user: " & NotifyTarget
  1657. End If
  1658. If CrashMode = True Then
  1659. If OSVersion = "4.0" Then
  1660. Wscript.Echo ""
  1661. Wscript.Echo "Monitoring IIS and all MTS server packages for crashes."
  1662. Wscript.echo "----------------------------------------------------------------------"
  1663. ElseIf CInt(OSBuildNumber) = 2195 Then
  1664. Wscript.Echo ""
  1665. Wscript.Echo "Monitoring IIS and all COM+ server applications"
  1666. Wscript.Echo "except for the System application for crashes."
  1667. Wscript.echo "----------------------------------------------------------------------"
  1668. ElseIf CInt(OSBuildNumber) > 2195 Then
  1669. Wscript.Echo ""
  1670. Wscript.Echo "Monitoring IIS and all COM+ server applications for crashes."
  1671. Wscript.echo "----------------------------------------------------------------------"
  1672. End If
  1673. ElseIf QuickMode = True Then
  1674. If OSVersion = "4.0" Then
  1675. Wscript.Echo ""
  1676. Wscript.Echo "Logging debug info for IIS and all MTS server packages."
  1677. Wscript.echo "----------------------------------------------------------------------"
  1678. ElseIf CInt(OSBuildNumber) = 2195 Then
  1679. Wscript.Echo ""
  1680. Wscript.Echo "Logging debug info for IIS and all COM+ server applications"
  1681. Wscript.Echo "except for the System application."
  1682. Wscript.echo "----------------------------------------------------------------------"
  1683. ElseIf CInt(OSBuildNumber) > 2195 Then
  1684. Wscript.Echo ""
  1685. Wscript.Echo "Logging debug info for IIS and all COM+ server applications."
  1686. Wscript.echo "----------------------------------------------------------------------"
  1687. End If
  1688. Else
  1689. If OSVersion = "4.0" Then
  1690. Wscript.Echo ""
  1691. Wscript.Echo "Dumping process info for IIS and all MTS server packages."
  1692. Wscript.echo "----------------------------------------------------------------------"
  1693. ElseIf CInt(OSBuildNumber) = 2195 Then
  1694. Wscript.Echo ""
  1695. Wscript.Echo "Dumping process info for IIS and all COM+ server applications"
  1696. Wscript.Echo "except for the System application."
  1697. Wscript.echo "----------------------------------------------------------------------"
  1698. ElseIf CInt(OSBuildNumber) > 2195 Then
  1699. Wscript.Echo ""
  1700. Wscript.Echo "Dumping process info for IIS and all COM+ server applications."
  1701. Wscript.echo "----------------------------------------------------------------------"
  1702. End If
  1703. End If
  1704. If CrashMode = true Then
  1705. If IISPid <> "" Then
  1706. PackageCount = PackageCount + 1
  1707. IISProcessCount = IISProcessCount + 1
  1708. Wscript.Echo "Attaching the CDB debugger to: IIS (inetinfo.exe)"
  1709. Wscript.Echo " (Process ID: " & IISPid & ")"
  1710. strShell = ShortInstallDir & "\cdb.exe -sfce -pn inetinfo.exe -c $<" & Chr(34) & CreateCDBScript(IISPid, "Inetinfo.exe") & Chr(34)
  1711. If DEBUGGING = TRUE Then
  1712. Wscript.echo "In DumpIIS(), just about to launch CDB.EXE with: " & strShell
  1713. End If
  1714. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  1715. Else
  1716. Wscript.echo "The '-IIS' switch was used, but IIS is not currently running."
  1717. End If
  1718. ElseIf QuickMode = true Then
  1719. If IISPid <> "" Then
  1720. PackageCount = PackageCount + 1
  1721. IISProcessCount = IISProcessCount + 1
  1722. If OSVer = "4.0" Then
  1723. Wscript.Echo "Logging debug info for: IIS (inetinfo.exe)"
  1724. Wscript.Echo " (Process ID: " & IISPid & ")"
  1725. strShell = ShortInstallDir & "\cdb.exe -sfce -pv -pn inetinfo.exe -c $<" & Chr(34) & CreateCDBScript(IISPid, "Inetinfo.exe") & Chr(34)
  1726. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  1727. Else
  1728. Wscript.Echo "Logging debug info for: IIS (inetinfo.exe)."
  1729. Wscript.Echo " (Process ID: " & IISPid & ")"
  1730. strShell = ShortInstallDir & "\cdb.exe -pv -pn inetinfo.exe -c $<" & Chr(34) & CreateCDBScript(IISPid, "Inetinfo.exe") & Chr(34)
  1731. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  1732. End If
  1733. Else
  1734. Wscript.echo "The '-IIS' switch was used, but IIS is not currently running."
  1735. End If
  1736. Else
  1737. If IISPid <> "" Then
  1738. PackageCount = PackageCount + 1
  1739. IISProcessCount = IISProcessCount + 1
  1740. Wscript.Echo "Dumping process: IIS (inetinfo.exe)"
  1741. Wscript.Echo " (Process ID: " & IISPid & ")"
  1742. strShell = ShortInstallDir & "\cdb.exe -sfce -pv -pn inetinfo.exe -c $<" & Chr(34) & CreateCDBScript(IISPid, "Inetinfo.exe") & Chr(34)
  1743. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  1744. Else
  1745. Wscript.echo "The '-IIS' switch was used, but IIS is not currently running."
  1746. End If
  1747. End If
  1748. 'Enumerate all running MTS / COM+ server packages that are currently running and attach the debugger to them . . .
  1749. while not objTextFile.AtEndofStream
  1750. str = objTextFile.ReadLine
  1751. Str = LTrim(Str)
  1752. If InStr(Str, "Mts:") Then
  1753. arResults= split(Str,":",-1,1)
  1754. arResults(1)=trim(arResults(1))
  1755. arResults(1)=Replace(arResults(1),"/",",")
  1756. arResults(1)=Replace(arResults(1),"\",",")
  1757. arResults(1)=Replace(arResults(1),"<","(")
  1758. arResults(1)=Replace(arResults(1),">",")")
  1759. arResults(1)=Replace(arResults(1),":","")
  1760. arResults(1)=Replace(arResults(1),"*","")
  1761. arResults(1)=Replace(arResults(1),"?","")
  1762. arResults(1)=Replace(arResults(1),"|","")
  1763. arResults(0)=LTrim(arResults(0))
  1764. WheresTheSpace = InStr(arResults(0)," ")
  1765. arResults(0)= Left(arResults(0),(WheresTheSpace-1))
  1766. If DEBUGGING Then
  1767. Wscript.Echo "Enumerating all COM+ & MTS Processes from Process_List.txt"
  1768. Wscript.Echo "The Package Name is: " & arResults(1)
  1769. Wscript.echo "The Package PID is: " & arResults(0)
  1770. End if
  1771. 'Dump all COM+ / MTS packages, including the system package if possible . . .
  1772. If arResults(1) <> "IIS In-Process Applications" Then 'Somtimes Inetinfo.exe shows up as "IIS In-Process Applications"
  1773. If QuickMode = true then
  1774. If OSVersion = "4.0" Then
  1775. PackageCount = PackageCount + 1
  1776. IISProcessCount = IISProcessCount + 1
  1777. Wscript.Echo "Logging debug info for: " & arResults(1)
  1778. Wscript.Echo " (Process ID: " & arResults(0) & ")"
  1779. strPackageName = Replace(Trim(arResults(1)), " ", "_")
  1780. If DEBUGGING = TRUE Then
  1781. Wscript.echo "In DumpIIS(), strPackageName = " & strPackageName
  1782. Wscript.echo ""
  1783. End If
  1784. strShell= ShortInstallDir & "\cdb.exe -sfce -pv -p " & arResults(0) & " -c $<" & Chr(34) & CreateCDBScript(arResults(0), strPackageName) & Chr(34)
  1785. If DEBUGGING = TRUE Then
  1786. Wscript.echo "In DumpIIS(), about to run the debugger with the following string, strShell = " & strShell
  1787. Wscript.echo ""
  1788. End If
  1789. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  1790. Else
  1791. PackageCount = PackageCount + 1
  1792. IISProcessCount = IISProcessCount + 1
  1793. Wscript.Echo "Logging debug info for: " & arResults(1)
  1794. Wscript.Echo " (Process ID: " & arResults(0) & ")"
  1795. If DEBUGGING = TRUE Then
  1796. Wscript.echo "In DumpIIS(), strPackageName = " & strPackageName
  1797. Wscript.echo ""
  1798. End If
  1799. strPackageName = Replace(Trim(arResults(1)), " ", "_")
  1800. strShell= ShortInstallDir & "\cdb.exe -sfce -pv -p " & arResults(0) & " -c $<" & Chr(34) & CreateCDBScript(arResults(0), strPackageName) & Chr(34)
  1801. If DEBUGGING = TRUE Then
  1802. Wscript.echo "In DumpIIS(), about to run the debugger with the following string, strShell = " & strShell
  1803. Wscript.echo ""
  1804. End If
  1805. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  1806. End If
  1807. ElseIf CrashMode = True Then
  1808. If OSVersion = "4.0" Then
  1809. PackageCount = PackageCount + 1
  1810. IISProcessCount = IISProcessCount + 1
  1811. Wscript.Echo "Attaching the CDB debugger to: " & arResults(1)
  1812. Wscript.Echo " (Process ID: " & arResults(0) & ")"
  1813. strPackageName = Replace(Trim(arResults(1)), " ", "_")
  1814. strPackageName = Replace(strPackageName, ",,", "-")
  1815. strPackageName = Replace(strPackageName, ",", "-")
  1816. If DEBUGGING = TRUE Then
  1817. Wscript.echo "In DumpIIS(), strPackageName = " & strPackageName
  1818. Wscript.echo ""
  1819. End If
  1820. strShell= ShortInstallDir & "\cdb.exe -sfce -p " & arResults(0) & " -c $<" & Chr(34) & CreateCDBScript(arResults(0), strPackageName) & Chr(34)
  1821. If DEBUGGING = TRUE Then
  1822. Wscript.echo "In DumpIIS(), about to run the debugger with the following string, strShell = " & strShell
  1823. Wscript.echo ""
  1824. End If
  1825. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  1826. Else
  1827. PackageCount = PackageCount + 1
  1828. IISProcessCount = IISProcessCount + 1
  1829. Wscript.Echo "Attaching the CDB debugger to: " & arResults(1)
  1830. Wscript.Echo " (Process ID: " & arResults(0) & ")"
  1831. strPackageName = Replace(Trim(arResults(1)), " ", "_")
  1832. strPackageName = Replace(strPackageName, ",,", "-")
  1833. strPackageName = Replace(strPackageName, ",", "-")
  1834. If DEBUGGING = TRUE Then
  1835. Wscript.echo "In DumpIIS(), strPackageName = " & strPackageName
  1836. Wscript.echo ""
  1837. End If
  1838. strShell= ShortInstallDir & "\cdb.exe -sfce -p " & arResults(0) & " -c $<" & Chr(34) & CreateCDBScript(arResults(0), strPackageName) & Chr(34)
  1839. If DEBUGGING = TRUE Then
  1840. Wscript.echo "In DumpIIS(), about to run the debugger with the following string, strShell = " & strShell
  1841. Wscript.echo ""
  1842. End If
  1843. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  1844. End If
  1845. Else
  1846. PackageCount = PackageCount + 1
  1847. IISProcessCount = IISProcessCount + 1
  1848. Wscript.Echo "Dumping process: " & arResults(1)
  1849. Wscript.Echo " (Process ID: " & arResults(0) & ")"
  1850. strPackageName = Replace(Trim(arResults(1)), " ", "_")
  1851. strPackageName = Replace(strPackageName, ",,", "-")
  1852. strPackageName = Replace(strPackageName, ",", "-")
  1853. If DEBUGGING = TRUE Then
  1854. Wscript.echo "In DumpIIS(), strPackageName = " & strPackageName
  1855. Wscript.echo ""
  1856. End If
  1857. strShell= ShortInstallDir & "\cdb.exe -sfce -pv -p " & arResults(0) & " -c $<" & Chr(34) & CreateCDBScript(arResults(0), strPackageName) & Chr(34)
  1858. If DEBUGGING = TRUE Then
  1859. Wscript.echo "In DumpIIS(), about to run the debugger with the following string, strShell = " & strShell
  1860. Wscript.echo ""
  1861. End If
  1862. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  1863. End If
  1864. End If
  1865. End if
  1866. wend
  1867. Else
  1868. If QuietMode = False Then
  1869. objshell.popup "The command 'tlist.exe -k' does not appear to have run properly from the " & InstallDir & " directory. AutodumpPlus can not continue.",,"AutodumpPlus",0
  1870. ErrorsDuringRuntime = True
  1871. Else
  1872. objShell.LogEvent 1, "The command 'tlist.exe -k' does not appear to have run properly from the " & InstallDir & " directory. AutodumpPlus can not continue."
  1873. wscript.echo "The command 'tlist.exe -k' does not appear to have run properly from the " & InstallDir & " directory. AutodumpPlus can not continue."
  1874. ErrorsDuringRuntime = True
  1875. End If
  1876. Wscript.quit 1
  1877. End if
  1878. objTextFile.Close
  1879. Set objTextFile = nothing
  1880. Set objFileSystem = nothing
  1881. Set objShell = nothing
  1882. End sub
  1883. '---------------------------------------------------------------------------------------------
  1884. ' Function: DumpAnyProc
  1885. ' This is the code used to dump any processes specified on the command line.
  1886. '---------------------------------------------------------------------------------------------
  1887. Sub DumpAnyProc()
  1888. On Error Resume Next
  1889. If DEBUGGING = TRUE Then
  1890. Wscript.echo ""
  1891. Wscript.echo "-----------------------------------"
  1892. Wscript.echo "In the DumpAnyProc function . . ."
  1893. Wscript.echo "-----------------------------------"
  1894. Wscript.echo ""
  1895. End If
  1896. Dim objFileSystem
  1897. Dim objTextFile
  1898. Dim Str
  1899. Dim i
  1900. Dim x,y
  1901. Dim LineNumber
  1902. Dim args
  1903. Dim PIDArgItems
  1904. Dim PidArgItemsCount
  1905. Dim ProcArgItems
  1906. Dim ProcArgItemsCount
  1907. Dim arResults
  1908. Dim objShell
  1909. Dim strShell
  1910. Dim versionFile
  1911. Dim TempCounter
  1912. Dim strPackageName
  1913. Dim strProcName
  1914. Dim PidMatch
  1915. Dim ProcessMatch
  1916. Dim ProcNamePidArray()
  1917. Dim FirstCall
  1918. FirstCall = True
  1919. LineNumber = 1
  1920. PidMatch = false
  1921. ProcessMatch = false
  1922. x = 0
  1923. Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  1924. Set objShell = CreateObject("Wscript.Shell")
  1925. 'Per the scripting team's advice, sleep for .5 second prior to calling this function.
  1926. Wscript.sleep 500
  1927. If CrashMode = true Then
  1928. If DEBUGGING = TRUE Then
  1929. Wscript.echo "In DumpAnyProc(), The Process_List.txt file should be located here: " & CrashDir & "\Process_List.txt"
  1930. Wscript.echo ""
  1931. End If
  1932. While not objFileSystem.FileExists(CrashDir & "\Process_List.txt")
  1933. Wscript.sleep 1000
  1934. If DEBUGGING = TRUE Then
  1935. wscript.echo "In DumpAnyProc(), The Process_List.txt file has not been created yet, sleeping for 1 second and trying again."
  1936. wscript.echo ""
  1937. End If
  1938. i = i +1
  1939. If i = 10 Then
  1940. If DEBUGGING = TRUE Then
  1941. wscript.echo "In DumpAnyProc(), Could not find the Process_List.txt file in the folder: " & CrashDir
  1942. wscript.echo "In DumpAnyProc(), Exiting AutodumpPlus now."
  1943. wscript.echo ""
  1944. End If
  1945. If QuietMode = False Then
  1946. objShell.PopUp "The file Process_List.txt could not be found in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again.",,"AutodumpPlus",0
  1947. Else
  1948. Wscript.echo "The file Process_List.txt could not be found in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1949. objShell.LogEvent 1, "The file Process_List.txt could not be found in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1950. ErrorsDuringRuntime = True
  1951. End If
  1952. If HangMode = True Then
  1953. DeleteDirectory(HangDir)
  1954. Else
  1955. DeleteDirectory(CrashDir)
  1956. End If
  1957. wscript.quit 1
  1958. End If
  1959. Wend
  1960. Else 'Running in Hang or Quick modes . . .
  1961. If DEBUGGING = TRUE Then
  1962. Wscript.echo "In DumpAnyProc(), The Process_List.txt file should be located here: " & HangDir & "\Process_List.txt"
  1963. End If
  1964. While not objFileSystem.FileExists(HangDir & "\Process_List.txt")
  1965. Wscript.sleep 1000
  1966. If DEBUGGING = TRUE Then
  1967. wscript.echo "In DumpAnyProc(), The Process_List.txt file has not been created yet, sleeping for 1 second and trying again."
  1968. wscript.echo ""
  1969. End If
  1970. i = i +1
  1971. If i = 10 Then
  1972. If DEBUGGING = TRUE Then
  1973. wscript.echo "In DumpAnyProc(), Could not find the Process_List.txt file in the folder: " & HangDir
  1974. wscript.echo "In DumpAnyProc(), Exiting AutodumpPlus now."
  1975. wscript.echo ""
  1976. End If
  1977. If QuietMode = False Then
  1978. objShell.PopUp "The file Process_List.txt could not be found in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again.",,"AutodumpPlus",0
  1979. Else
  1980. Wscript.echo "The file Process_List.txt could not be found in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1981. objShell.LogEvent 1, "The file Process_List.txt could not be found in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  1982. ErrorsDuringRuntime = True
  1983. End If
  1984. If HangMode = True Then
  1985. DeleteDirectory(HangDir)
  1986. Else
  1987. DeleteDirectory(CrashDir)
  1988. End If
  1989. wscript.quit 1
  1990. End If
  1991. Wend
  1992. End If
  1993. If HangMode = True Then
  1994. Set objTextFile = objFileSystem.OpenTextFile(HangDir & "\Process_List.txt",ForReading,TristateUseDefault)
  1995. Else
  1996. Set objTextFile = objFileSystem.OpenTextFile(CrashDir & "\Process_List.txt",ForReading,TristateUseDefault)
  1997. End If
  1998. i = 0
  1999. While objTextFile.AtEndOfStream
  2000. 'Close the text file to let it finish writing and to get a new copy . . .
  2001. objTextFile.Close
  2002. wscript.sleep 1000
  2003. If DEBUGGING = TRUE Then
  2004. wscript.echo "In DumpAnyProc(), Waiting for Process_List.txt to finish writing (sleeping 1 second). . . "
  2005. wscript.echo ""
  2006. End If
  2007. i = i +1
  2008. If i = 10 Then
  2009. If HangMode = True Then
  2010. If DEBUGGING = TRUE Then
  2011. wscript.echo "In DumpAnyProc(), Process_List.txt was never closed (finished writing) in the folder: " & HangDir
  2012. wscript.echo "In DumpAnyProc(), Exiting AutodumpPlus now."
  2013. wscript.echo ""
  2014. End If
  2015. If QuietMode = False Then
  2016. objShell.PopUp "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again.",,"AutodumpPlus",0
  2017. Else
  2018. Wscript.echo "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  2019. objShell.LogEvent 1, "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & HangDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  2020. ErrorsDuringRuntime = True
  2021. End If
  2022. DeleteDirectory(HangDir)
  2023. wscript.quit 1
  2024. Else
  2025. If DEBUGGING = TRUE Then
  2026. wscript.echo "In DumpAnyProc(), Process_List.txt was never closed (finished writing) in the folder: " & CrashDir
  2027. wscript.echo "In DumpAnyProc(), Exiting AutodumpPlus now."
  2028. wscript.echo ""
  2029. End If
  2030. If QuietMode = False Then
  2031. objShell.PopUp "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again.",,"AutodumpPlus",0
  2032. Else
  2033. Wscript.echo "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  2034. objShell.LogEvent 1, "The file Process_List.txt was never closed (finished writing) by tlist.exe in the " & CrashDir & " directory after waiting for 10 seconds. This could indicate that there was a problem running tlist.exe or that the file could not be read using the Scripting.FileSystemObject. Please try running tlist.exe manually from the " & installdir & " directory or re-register scrrun.dll and try running AutodumpPlus again."
  2035. ErrorsDuringRuntime = True
  2036. End If
  2037. DeleteDirectory(CrashDir)
  2038. wscript.quit 1
  2039. End If
  2040. End If
  2041. 'Open the text file again before looping . . .
  2042. If HangMode = True Then
  2043. Set objTextFile = objFileSystem.OpenTextFile(HangDir & "\Process_List.txt",ForReading,TristateUseDefault)
  2044. Else
  2045. Set objTextFile = objFileSystem.OpenTextFile(CrashDir & "\Process_List.txt",ForReading,TristateUseDefault)
  2046. End If
  2047. Wend
  2048. If IISMode = False then
  2049. If HangMode = true and QuickMode = true Then
  2050. Wscript.Echo "The '-quick' switch was used, AutodumpPlus is running in 'quick hang' mode."
  2051. ElseIf HangMode = true Then
  2052. Wscript.echo "The '-hang' switch was used, AutodumpPlus is running in 'hang' mode."
  2053. End If
  2054. If CrashMode = true Then
  2055. Wscript.Echo "The '-crash' switch was used, AutodumpPlus is running in 'crash' mode."
  2056. End If
  2057. If QuietMode = true Then
  2058. Wscript.Echo "The '-quiet' switch was used, AutodumpPlus will not display any modal dialog boxes."
  2059. End If
  2060. If OSwitchUsed = true Then
  2061. Wscript.Echo "The '-o' switch was used. AutodumpPlus will place all files in"
  2062. Wscript.echo "the following directory: " & OutputDir
  2063. End If
  2064. If NotifyAdmin = true Then
  2065. Wscript.Echo "The '-notify' switch was used. AutodumpPlus will send notification to"
  2066. Wscript.echo "the following computer or user: " & NotifyTarget
  2067. End If
  2068. End If
  2069. If GenericModePID = True Then
  2070. PidArgItems = GenericProcessPIDDictionary.Items
  2071. PidArgItemsCount = GenericProcessPIDDictionary.Count
  2072. If DEBUGGING = TRUE Then
  2073. wscript.echo "In DumpAnyProc, in the function to get the process name, given the '-p' switch."
  2074. wscript.echo ""
  2075. End If
  2076. For i = 0 to PidArgItemsCount -1
  2077. If HangMode = True Then
  2078. Set objTextFile = objFileSystem.OpenTextFile(HangDir & "\Process_List.txt",ForReading,TristateUseDefault)
  2079. Else
  2080. Set objTextFile = objFileSystem.OpenTextFile(CrashDir & "\Process_List.txt",ForReading,TristateUseDefault)
  2081. End If
  2082. While not objTextFile.AtEndofStream
  2083. str = objTextFile.ReadLine
  2084. Str = LTrim(Str)
  2085. arResults= split(Str," ",-1,1)
  2086. arResults(1)=trim(arResults(1))
  2087. arResults(1)=Replace(arResults(1),"/",",")
  2088. arResults(1)=Replace(arResults(1),"\",",")
  2089. arResults(1)=Replace(arResults(1),"<","(")
  2090. arResults(1)=Replace(arResults(1),">",")")
  2091. arResults(1)=Replace(arResults(1),":","")
  2092. arResults(1)=Replace(arResults(1),"*","")
  2093. arResults(1)=Replace(arResults(1),"?","")
  2094. arResults(1)=Replace(arResults(1),"|","")
  2095. If Trim(arResults(0)) = PidArgItems(i) Then
  2096. PidMatch = True
  2097. strProcName = Trim(arResults(1))
  2098. If DEBUGGING = TRUE Then
  2099. wscript.echo "In DumpAnyProc(), Logging debug info for: Process - " & strProcName & " with PID - " & PidArgItems(i)
  2100. wscript.echo ""
  2101. End If
  2102. End If
  2103. Wend
  2104. If CrashMode = True Then
  2105. strShell= ShortInstallDir & "\cdb.exe -sfce -p " & PidArgItems(i) & " -c $<" & Chr(34) & CreateCDBScript(PidArgItems(i), strProcName) & Chr(34)
  2106. If DEBUGGING = TRUE Then
  2107. wscript.echo "In DumpAnyProc(), running in CrashMode, strShell = " & strShell
  2108. wscript.echo ""
  2109. End If
  2110. Else
  2111. strShell= ShortInstallDir & "\cdb.exe -sfce -pv -p " & PidArgItems(i) & " -c $<" & Chr(34) & CreateCDBScript(PidArgItems(i), strProcName) & Chr(34)
  2112. If DEBUGGING = TRUE Then
  2113. wscript.echo "In DumpAnyProc(), running in Hang or Quick mode, strShell = " & strShell
  2114. wscript.echo ""
  2115. End If
  2116. End If
  2117. If PidMatch = True Then
  2118. If FirstCall = True Then
  2119. If CrashMode = True Then
  2120. Wscript.echo ""
  2121. Wscript.echo "Monitoring the processes that were specified"
  2122. Wscript.echo "on the command line for unhandled exceptions."
  2123. Wscript.echo "----------------------------------------------------------------------"
  2124. ElseIf QuickMode = True Then
  2125. Wscript.echo ""
  2126. Wscript.echo "Logging debug info for the processes that were"
  2127. Wscript.echo "specified on the command line."
  2128. Wscript.echo "----------------------------------------------------------------------"
  2129. Else
  2130. Wscript.echo ""
  2131. Wscript.echo "Dumping process information for the processes"
  2132. Wscript.echo "that were specified on the command line."
  2133. Wscript.echo "----------------------------------------------------------------------"
  2134. End If
  2135. End If
  2136. FirstCall = False
  2137. If CrashMode = True Then
  2138. wscript.echo "Attaching the CDB debugger to: Process - " & strProcName & " with PID - " & PidArgItems(i)
  2139. ElseIf QuickMode = True Then
  2140. wscript.echo "Logging debug info for: Process - " & strProcName & " with PID - " & PidArgItems(i)
  2141. Else
  2142. wscript.echo "Dumping Process: " & strProcName & " with PID - " & PidArgItems(i)
  2143. End If
  2144. 'Now run the debugger . . .
  2145. If PackageCount < MAX_APPLICATIONS_TO_DEBUG Then
  2146. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  2147. Else
  2148. wscript.echo "MAX_APPLICATIONS_TO_DEBUG has been exceeded, skipping the above process . . ."
  2149. End If
  2150. PackageCount = PackageCount + 1
  2151. Else
  2152. If QuietMode = False Then
  2153. objShell.PopUp "One or more process ID's specified on the command line using the '-p' switch, were not found. Please doublecheck the process ID(s) and run AutodumpPlus again.",,"AutodumpPlus",0
  2154. ErrorsDuringRuntime = True
  2155. Else
  2156. objShell.LogEvent 1, "One or more process ID's specified on the command line using the '-p' switch, were not found. Please doublecheck the process ID(s) and run AutodumpPlus again."
  2157. wscript.echo "One or more process ID's specified on the command line using the '-p' switch, were not found. Please doublecheck the process ID(s) and run AutodumpPlus again."
  2158. ErrorsDuringRuntime = True
  2159. End If
  2160. objTextFile.Close
  2161. If HangMode = True Then
  2162. DeleteDirectory(HangDir)
  2163. Else
  2164. DeleteDirectory(CrashDir)
  2165. End If
  2166. Wscript.quit 1
  2167. End If
  2168. Next
  2169. End If
  2170. If GenericModeProcessName = true Then
  2171. ProcArgItems = GenericProcessNameDictionary.Items 'Store the GenericProcessNameDictionary items collection in an array
  2172. ProcArgItemsCount = GenericProcessNameDictionary.Count 'Get the count of all the items in the array
  2173. If DEBUGGING = TRUE Then
  2174. Wscript.echo "In DumpAnyProc, in the function to get the process ID, given the '-pn' switch."
  2175. Wscript.echo ""
  2176. End If
  2177. For i = 0 to ProcArgItemsCount -1
  2178. x = 0
  2179. If HangMode = True Then
  2180. Set objTextFile = objFileSystem.OpenTextFile(HangDir & "\Process_List.txt",ForReading,TristateUseDefault)
  2181. Else
  2182. Set objTextFile = objFileSystem.OpenTextFile(CrashDir & "\Process_List.txt",ForReading,TristateUseDefault)
  2183. End If
  2184. While not objTextFile.AtEndofStream
  2185. str = objTextFile.ReadLine
  2186. Str = LTrim(Str)
  2187. arResults= split(Str," ",-1,1)
  2188. arResults(1)=trim(arResults(1))
  2189. arResults(1)=Replace(arResults(1),"/",",")
  2190. arResults(1)=Replace(arResults(1),"\",",")
  2191. arResults(1)=Replace(arResults(1),"<","(")
  2192. arResults(1)=Replace(arResults(1),">",")")
  2193. arResults(1)=Replace(arResults(1),":","")
  2194. arResults(1)=Replace(arResults(1),"*","")
  2195. arResults(1)=Replace(arResults(1),"?","")
  2196. arResults(1)=Replace(arResults(1),"|","")
  2197. If UCase(arResults(1)) = UCase(ProcArgItems(i)) Then
  2198. ProcessMatch = True
  2199. x = x + 1
  2200. End If
  2201. Wend
  2202. objTextFile.Close
  2203. 'If the process name specified is invalid, display an error and then quit.
  2204. If ProcessMatch = False Then
  2205. If QuietMode = False Then
  2206. objShell.PopUp "One or more process names specified on the command line using the '-pn' switch, were not found. Please doublecheck the process name(s) and run AutodumpPlus again.",,"AutodumpPlus",0
  2207. ErrorsDuringRuntime = True
  2208. Else
  2209. objShell.LogEvent 1, "One or more process names specified on the command line using the '-pn' switch, were not found. Please doublecheck the process name(s) and run AutodumpPlus again."
  2210. wscript.echo "One or more process names specified on the command line using the '-pn' switch, were not found. Please doublecheck the process name(s) and run AutodumpPlus again."
  2211. ErrorsDuringRuntime = True
  2212. End If
  2213. 'If there was nothing to dump or log, then display an error and clean up the directory
  2214. If IISMode = False Then
  2215. If HangMode = True Then
  2216. 'Wscript.echo HangDir
  2217. DeleteDirectory(HangDir)
  2218. Else
  2219. 'Wscript.echo CrashDir
  2220. DeleteDirectory(CrashDir)
  2221. End If
  2222. Wscript.quit 1
  2223. End If
  2224. End If
  2225. ReDim ProcNamePidArray(x)
  2226. x = 0
  2227. If HangMode = True Then
  2228. Set objTextFile = objFileSystem.OpenTextFile(HangDir & "\Process_List.txt",ForReading,TristateUseDefault)
  2229. Else
  2230. Set objTextFile = objFileSystem.OpenTextFile(CrashDir & "\Process_List.txt",ForReading,TristateUseDefault)
  2231. End If
  2232. If DEBUGGING = TRUE Then
  2233. wscript.echo "In DumpAnyProc, in GenericModeProcessName function."
  2234. wscript.echo ""
  2235. End If
  2236. If objTextFile.AtEndOfStream Then
  2237. wscript.echo "objTextFile is at EndOfStream"
  2238. wscript.echo ""
  2239. End If
  2240. While not objTextFile.AtEndofStream
  2241. str = objTextFile.ReadLine
  2242. Str = LTrim(Str)
  2243. arResults= split(Str," ",-1,1)
  2244. arResults(1)=trim(arResults(1))
  2245. arResults(1)=Replace(arResults(1)," ",",")
  2246. If UCase(arResults(1)) = UCase(ProcArgItems(i)) Then
  2247. ProcNamePidArray(x) = Trim(arResults(0))
  2248. If DEBUGGING = TRUE Then
  2249. wscript.echo "In DumpAnyProc(), ProcNamePidArray(x) = " & ProcNamePidArray(x)
  2250. wscript.echo ""
  2251. End If
  2252. x = x + 1
  2253. End If
  2254. Wend
  2255. If DEBUGGING = TRUE Then
  2256. wscript.echo "In DumpAnyProc(), Total number of CDB sessions to launch: " & UBound(ProcNamePidArray, 1)
  2257. wscript.echo ""
  2258. End If
  2259. For y = 0 to UBound(ProcNamePidArray, 1) - 1 'The For . . . Each syntax seemed to have an extra, empty array element which was causing problems
  2260. If DEBUGGING = True Then
  2261. Wscript.echo ""
  2262. Wscript.echo "In the DumpAnyProc(), PID = " & ProcNamePidArray(y)
  2263. End If
  2264. If CrashMode = true Then
  2265. strShell= ShortInstallDir & "\cdb.exe -sfce -p " & ProcNamePidArray(y) & " -c $<" & Chr(34) & CreateCDBScript(ProcNamePidArray(y), Trim(UCase(ProcArgItems(i)))) & Chr(34)
  2266. If DEBUGGING = True Then
  2267. Wscript.echo "In the DumpAnyProc(), strShell = " & strShell
  2268. Wscript.echo ""
  2269. End If
  2270. Else
  2271. strShell= ShortInstallDir & "\cdb.exe -sfce -pv -p " & ProcNamePidArray(y) & " -c $<" & Chr(34) & CreateCDBScript(ProcNamePidArray(y), Trim(UCase(ProcArgItems(i)))) & Chr(34)
  2272. If DEBUGGING = True Then
  2273. Wscript.echo "In the DumpAnyProc(), strShell = " & strShell
  2274. Wscript.echo ""
  2275. End If
  2276. End If
  2277. If FirstCall = True Then
  2278. If CrashMode = True Then
  2279. Wscript.echo ""
  2280. Wscript.echo "Monitoring the processes that were specified on the command line"
  2281. Wscript.echo "for unhandled exceptions."
  2282. Wscript.echo "----------------------------------------------------------------------"
  2283. ElseIf QuickMode = True Then
  2284. Wscript.echo ""
  2285. Wscript.echo "Logging debug info for the processes that were specified on the command line."
  2286. Wscript.echo "----------------------------------------------------------------------"
  2287. Else
  2288. Wscript.echo ""
  2289. Wscript.echo "Dumping process information for the processes that were specified"
  2290. Wscript.echo "on the command line."
  2291. Wscript.echo "----------------------------------------------------------------------"
  2292. End If
  2293. End If
  2294. FirstCall = False
  2295. If CrashMode = true Then
  2296. wscript.echo "Attaching the CDB debugger to: Process - " & Trim(UCase(ProcArgItems(i))) & " with PID - " & ProcNamePidArray(y)
  2297. ElseIf QuickMode = true Then
  2298. wscript.echo "Logging debug info for: Process - " & Trim(UCase(ProcArgItems(i))) & " with PID - " & ProcNamePidArray(y)
  2299. Else
  2300. wscript.echo "Dumping Process: " & Trim(UCase(ProcArgItems(i))) & " with PID - " & ProcNamePidArray(y)
  2301. End If
  2302. If PackageCount < MAX_APPLICATIONS_TO_DEBUG Then
  2303. objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  2304. Else
  2305. wscript.echo "MAX_APPLICATIONS_TO_DEBUG has been exceeded, skipping the above process . . ."
  2306. End If
  2307. PackageCount = PackageCount + 1
  2308. ' objShell.Run strShell,MINIMIZE_NOACTIVATE,FALSE
  2309. Next
  2310. Next
  2311. End If
  2312. End Sub
  2313. '---------------------------------------------------------------------------------------------
  2314. ' Function: ShowStatus
  2315. ' This is the code used to display the pop-up summary at the end of AutodumpPlus.
  2316. '---------------------------------------------------------------------------------------------
  2317. Sub ShowStatus(OSVersion)
  2318. On Error Resume Next
  2319. If DEBUGGING = TRUE Then
  2320. Wscript.echo ""
  2321. Wscript.echo "-----------------------------------"
  2322. Wscript.echo "In the ShowStatus() function . . ."
  2323. Wscript.echo "-----------------------------------"
  2324. Wscript.echo ""
  2325. End If
  2326. Dim objFileSystem
  2327. Dim versionFile
  2328. Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  2329. If PackageCount = 1 Then
  2330. If QuickMode = true Then
  2331. If OSVersion = "4.0" Then
  2332. If QuietMode = False Then
  2333. objshell.popup "AutodumpPlus is now running in 'quick' mode and is logging information for all of the threads in the process you have chosen to examine. Quick mode is usually faster than 'hang' mode, however you may still see " & PackageCount & " minimized command shell window which is logging information about this process. AutodumpPlus is finished running when this window disappears. After AutodumpPlus completes, please check the " & HangDir & " directory to verify the log file for this process was created!",,"AutodumpPlus",0
  2334. Else
  2335. objShell.LogEvent 0, "AutodumpPlus is now running in 'quick' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2336. End If
  2337. Else
  2338. If QuietMode = False Then
  2339. objshell.popup "AutodumpPlus is now running in 'quick' mode and is logging information for all of the threads in the process you have chosen to examine. Quick mode is usually faster than 'hang' mode, however you may still see " & PackageCount & " minimized command shell window which is logging information about this process. AutodumpPlus is finished running when this window disappears. After AutodumpPlus completes, please check the " & HangDir & " directory to verify the log file for this process was created!",,"AutodumpPlus",0
  2340. Else
  2341. objShell.LogEvent 0, "AutodumpPlus is now running in 'quick' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2342. End If
  2343. End If
  2344. ElseIf CrashMode = True Then
  2345. If OSVersion = "4.0" Then
  2346. If QuietMode = False Then
  2347. objshell.popup "AutodumpPlus is now running in 'crash' mode and has attached the CDB debugger to the process you have chosen to monitor for crashes. You should see " & PackageCount & " minimized debugger window which is monitoring this process for any exceptions. A log file will be generated for the process you have chosen to monitor and when a 1st chance exception occurs, it will be logged to this log file and a mini-memory dump will be produced. If a 2nd chance exception occurs, it will be logged to this log file and a full memory dump will be produced. AutodumpPlus has probably captured a crash if and when the minimized debugger window disappears. If the process hangs while running in crash mode, or if you wish to stop debugging the process, please press CTRL-C in the minimized debugger window to stop debugging, and then re-start the process if necessary. After AutodumpPlus completes, please check the " & CrashDir & " directory to verify log files and possibly memory dump files for this process were created!",,"AutodumpPlus",0
  2348. Else
  2349. objShell.LogEvent 0, "AutodumpPlus is now running in 'crash' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2350. End If
  2351. Else
  2352. If QuietMode = False Then
  2353. objshell.popup "AutodumpPlus is now running in 'crash' mode and has attached the CDB debugger to the process you have chosen to monitor for crashes. You should see " & PackageCount & " minimized debugger window which is monitoring this process for any exceptions. A log file will be generated for the process you have chosen to monitor and when a 1st chance exception occurs, it will be logged to this log file and a mini-memory dump will be produced. If a 2nd chance exception occurs, it will be logged to this log file and a full memory dump will be produced. AutodumpPlus has probably captured a crash if and when the minimized debugger window disappears. If the process hangs while running in crash mode, or if you wish to stop debugging the process, please press CTRL-C in the minimized debugger window to stop debugging, and then re-start the process if necessary. After AutodumpPlus completes, please check the " & CrashDir & " directory to verify log files and possibly memory dump files for this process were created!",,"AutodumpPlus",0
  2354. Else
  2355. objShell.LogEvent 0, "AutodumpPlus is now running in 'crash' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2356. End If
  2357. End If
  2358. Else
  2359. If OSVersion = "4.0" Then
  2360. If QuietMode = False Then
  2361. objshell.popup "AutodumpPlus is now dumping the process you have chosen to examine. Depending upon the size of the process being dumped, AutodumpPlus could take anywhere from a few seconds to a few minutes to complete. You should see " & PackageCount & " minimized command shell window which is dumping the process. AutodumpPlus is finished when this window disappears. After AutodumpPlus completes, please check the " & HangDir & " directory to verify the memory dump was created!",,"AutodumpPlus",0
  2362. Else
  2363. objShell.LogEvent 0, "AutodumpPlus is now running in 'hang' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2364. End If
  2365. Else
  2366. If QuietMode = False Then
  2367. objshell.popup "AutodumpPlus is now dumping the process you have chosen to examine. Depending upon the size of the process being dumped, AutodumpPlus could take anywhere from a few seconds to a few minutes to complete. You should see " & PackageCount & " minimized command shell window which is dumping the process. AutodumpPlus is finished when this window disappears. After AutodumpPlus completes, please check the " & HangDir & " directory to verify the memory dump was created!",,"AutodumpPlus",0
  2368. Else
  2369. objShell.LogEvent 0, "AutodumpPlus is now running in 'hang' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2370. End If
  2371. End If
  2372. End If
  2373. ElseIf PackageCount > 0 Then
  2374. If QuickMode = true Then
  2375. If OSVersion = "4.0" Then
  2376. If QuietMode = False Then
  2377. objshell.popup "AutodumpPlus is now running in 'quick' mode and is logging information for all of the threads in the processes you have chosen to examine. Quick mode is usually faster than 'hang' mode, however you may still see at least " & PackageCount & " minimized command shell windows which are logging information about these processes. AutodumpPlus is finished running when these windows disappear. After AutodumpPlus completes, please check the " & HangDir & " directory to verify the log files for each process were created!",,"AutodumpPlus",0
  2378. Else
  2379. objShell.LogEvent 0, "AutodumpPlus is now running in 'quick' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2380. End If
  2381. Else
  2382. If QuietMode = False Then
  2383. objshell.popup "AutodumpPlus is now running in 'quick' mode and is logging information for all of the threads in the processes you have chosen to examine. Quick mode is usually faster than 'hang' mode, however you may still see at least " & PackageCount & " minimized command shell windows which are logging information about these processes. AutodumpPlus is finished running when these windows disappear. After AutodumpPlus completes, please check the " & HangDir & " directory to verify the log files for each process were created!",,"AutodumpPlus",0
  2384. Else
  2385. objShell.LogEvent 0, "AutodumpPlus is now running in 'quick' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2386. End If
  2387. End If
  2388. ElseIf CrashMode = true Then
  2389. If OSVersion = "4.0" Then
  2390. If QuietMode = False Then
  2391. objshell.popup "AutodumpPlus is now running in 'crash' mode and has attached the CDB debugger to the processes you have chosen to monitor for crashes. You should see " & PackageCount & " minimized debugger windows which are monitoring these processes for any exceptions. A log file will be generated for each process you have chosen to monitor and when a 1st chance exception occurs, it will be logged to this log file and a mini-memory dump will be produced. If a 2nd chance exception occurs, it will be logged to this log file and a full memory dump will be produced. AutodumpPlus has probably captured a crash if and when any of these minimized debugger windows disappear. If any of these processes hang while running in crash mode, or if you wish to stop debugging a process that has not crashed, please press CTRL-C in ALL minimized debugger windows to stop debugging, and then re-start the processes if necessary. After AutodumpPlus completes, please check the " & CrashDir & " directory to verify log files and possibly memory dump files for these processes were created!",,"AutodumpPlus",0
  2392. Else
  2393. objShell.LogEvent 0, "AutodumpPlus is now running in 'crash' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2394. End If
  2395. Else
  2396. If QuietMode = False Then
  2397. objshell.popup "AutodumpPlus is now running in 'crash' mode and has attached the CDB debugger to the processes you have chosen to monitor for crashes. You should see " & PackageCount & " minimized debugger windows which are monitoring these processes for any exceptions. A log file will be generated for each process you have chosen to monitor and when a 1st chance exception occurs, it will be logged to this log file and a mini-memory dump will be produced. If a 2nd chance exception occurs, it will be logged to this log file and a full memory dump will be produced. AutodumpPlus has probably captured a crash if and when any of these minimized debugger windows disappear. If any of these processes hang while running in crash mode, or if you wish to stop debugging a process that has not crashed, please press CTRL-C in ALL minimized debugger windows to stop debugging, and then re-start the processes if necessary. After AutodumpPlus completes, please check the " & CrashDir & " directory to verify log files and possibly memory dump files for these processes were created!",,"AutodumpPlus",0
  2398. Else
  2399. objShell.LogEvent 0, "AutodumpPlus is now running in 'crash' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2400. End If
  2401. End If
  2402. Else
  2403. If OSVersion = "4.0" Then
  2404. If QuietMode = False Then
  2405. objshell.popup "AutodumpPlus is now dumping the processes you have chosen to examine. Depending upon the number of processes being dumped, AutodumpPlus could take anywhere from a few seconds to a few minutes to complete. You should see at least " & PackageCount & " minimized command shell windows which are dumping processes. AutodumpPlus is finished dumping processes when these windows disappear. After AutodumpPlus completes, please check the " & HangDir & " directory to verify the memory dumps were created!",,"AutodumpPlus",0
  2406. Else
  2407. objShell.LogEvent 0, "AutodumpPlus is now running in 'hang' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2408. End If
  2409. Else
  2410. If QuietMode = False Then
  2411. objshell.popup "AutodumpPlus is now dumping the processes you have chosen to examine. Depending upon the number of processes being dumped, AutodumpPlus could take anywhere from a few seconds to a few minutes to complete. You should see at least " & PackageCount & " minimized command shell windows which are dumping processes. AutodumpPlus is finished dumping processes when these windows disappear. After AutodumpPlus completes, please check the " & HangDir & " directory to verify the memory dumps were created!",,"AutodumpPlus",0
  2412. Else
  2413. objShell.LogEvent 0, "AutodumpPlus is now running in 'hang' mode with the '-quiet' switch, and was started at: " & DateTimeStamp & "."
  2414. End If
  2415. End If
  2416. End If
  2417. Else
  2418. 'There were no processes to dump based on the specified command line criteria, display an error and quit.
  2419. If QuietMode = False Then
  2420. objshell.popup "There were no processes found to examine based on the parameters specified on the command line. If the '-iis' switch was used, please ensure that IIS is running. If the '-pn' or '-p' switches were used, please ensure you typed the process name correctly or that you specified the right Process ID.",,"AutodumpPlus",0
  2421. Else
  2422. wscript.echo "There were no processes found to examine based on the parameters specified on the command line. If the '-iis' switch was used, please ensure that IIS is running. If the '-pn' or '-p' switches were used, please ensure you typed the process name correctly or that you specified the right Process ID."
  2423. objShell.LogEvent 0, "There were no processes found to examine based on the parameters specified on the command line. If the '-iis' switch was used, please ensure that IIS is running. If the '-pn' or '-p' switches were used, please ensure you typed the process name correctly or that you specified the right Process ID."
  2424. End If
  2425. 'Clean up the directory since no output was produced.
  2426. If Crashmode = true Then
  2427. DeleteDirectory(CrashDir)
  2428. Else
  2429. DeleteDirectory(HangDir)
  2430. End If
  2431. Wscript.quit 1
  2432. End If
  2433. If CrashMode = true Then
  2434. err.clear
  2435. Set versionFile = objFileSystem.CreateTextFile(CrashDir & "\AutodumpPlus-report.txt",True)
  2436. If Err.number <> 0 Then
  2437. wscript.echo "Error encountered creating AutodumpPlus-report.txt"
  2438. wscript.echo "Error Description: " & err.description
  2439. wscript.echo "Error Number: " & err.number
  2440. End If
  2441. Else
  2442. err.clear
  2443. Set versionFile = objFileSystem.CreateTextFile(HangDir & "\AutodumpPlus-report.txt",True)
  2444. If Err.number <> 0 Then
  2445. wscript.echo "Error encountered creating AutodumpPlus-report.txt"
  2446. wscript.echo "Error Description: " & err.description
  2447. wscript.echo "Error Number: " & err.number
  2448. End If
  2449. End If
  2450. If DEBUGGING = TRUE Then
  2451. wscript.echo "In ShowStatus(), about to create AutodumpPlus-report.txt"
  2452. wscript.echo ""
  2453. End If
  2454. versionFile.writeline "'********************************************************************"
  2455. versionFile.writeline "'* File: AutodumpPlus-report.txt"
  2456. versionFile.writeline "'* AutodumpPlus version: " & VERSION
  2457. versionFile.writeline "'* Debuggers Installation Directory: " & InstallDir
  2458. versionFile.writeline "'* AutodumpPlus was run on: " & ComputerName
  2459. If HangMode = True Then
  2460. versionFile.writeline "'* Output Directory: " & HangDir
  2461. Else
  2462. versionFile.writeline "'* Output Directory: " & CrashDir
  2463. End If
  2464. If OSVer = "4.0" Then
  2465. versionFile.writeline "'* AutodumpPlus was run on NT 4.0."
  2466. Else
  2467. versionFile.writeline "'* AutodumpPlus was run on Windows 2000 or higher."
  2468. End If
  2469. If HangMode = True Then
  2470. versionFile.writeline "'* AutodumpPlus was run with the '-hang' switch."
  2471. End If
  2472. If QuickMode = true Then
  2473. versionFile.writeline "'* AutodumpPlus was run with the '-quick' switch."
  2474. End If
  2475. If CrashMode = true Then
  2476. versionFile.writeline "'* AutodumpPlus was run with the '-crash' switch."
  2477. End If
  2478. If PageHeapMode = true Then
  2479. versionFile.writeline "'* AutodumpPlus was run with the '-pageheap' switch."
  2480. End If
  2481. If QuietMode = true Then
  2482. versionFile.writeline "'* AutodumpPlus was run with the '-quiet' switch."
  2483. End If
  2484. If IISMode = True Then
  2485. versionFile.writeline "'* AutodumpPlus was run with the '-IIS' switch."
  2486. versionFile.writeline "'* IIS version: " & IISVer
  2487. End If
  2488. versionFile.writeline "'*"
  2489. versionFile.writeline "'* AutodumpPlus's constants had the following values:"
  2490. versionFile.writeline "'* DEBUGGING = " & DEBUGGING
  2491. versionFile.writeline "'* Full_Dump_on_CONTRL_C = " & Full_Dump_on_CONTRL_C
  2492. versionFile.writeline "'* Create_Full_Dump_on_1st_Chance_Exception = " & Create_Full_Dump_on_1st_Chance_Exception
  2493. versionFile.writeline "'* No_Dump_on_1st_Chance_Exception = " & No_Dump_on_1st_Chance_Exception
  2494. versionFile.writeline "'* Dump_on_EH_Exceptions = " & Dump_on_EH_Exceptions
  2495. versionFile.writeline "'* Dump_on_Unknown_Exceptions = " & Dump_on_Unknown_Exceptions
  2496. versionFile.writeline "'* Dump_Stack_on_DLL_Load = " & Dump_Stack_on_DLL_Load
  2497. versionFile.writeline "'* Dump_Stack_on_DLL_UnLoad = " & Dump_Stack_on_DLL_UnLoad
  2498. versionFile.writeline "'* No_CrashMode_Log = " & No_CrashMode_Log
  2499. versionFile.writeline "'* No_Free_Space_Checking = " & No_Free_Space_Checking
  2500. versionFile.writeline "'* "
  2501. versionFile.writeline "'* Date & Time AutodumpPlus was run: " & Now
  2502. If ErrorsDuringRuntime = True Then
  2503. versionFile.writeline "Error and warning information:"
  2504. versionFile.writeline "AutodumpPlus encountered one or more errors or warnings. Please check the event log for more information."
  2505. End If
  2506. If SymPathError = True Then
  2507. versionFile.writeline "'* WARNING! An '_NT_SYMBOL_PATH' environment variable is not set, as a result AutodumpPlus will be forced to use 'export' symbols (if present) to resolve function names in the stack trace information for each thread listed in the log file for the processes being debugged. To resolve this warning, please copy the appropriate symbols to a directory on the server and then create an environment variable with a name of '_NT_SYMBOL_PATH' and a value containing the path to the proper symbols (i.e. c:\winnt\symbols) before running AutodumpPlus in quick or crash modes again. NOTE: After creating the '_NT_SYMBOL_PATH' system environment variable you will need to close the current command shell and open a new one before running AutodumpPlus again."
  2508. End If
  2509. versionFile.writeline "'********************************************************************"
  2510. versionFile.close
  2511. End Sub
  2512. '---------------------------------------------------------------------------------------------
  2513. ' Function: PrintHelp
  2514. ' This is the code used to display the verbose help information.
  2515. '---------------------------------------------------------------------------------------------
  2516. Sub PrintHelp()
  2517. On Error Resume Next
  2518. If DEBUGGING = TRUE Then
  2519. Wscript.echo ""
  2520. Wscript.echo "-----------------------------------"
  2521. Wscript.echo "In the PrintHelp() function . . ."
  2522. Wscript.echo "-----------------------------------"
  2523. Wscript.echo ""
  2524. End If
  2525. Wscript.Echo "--------------------------------------------------------------------------------"
  2526. Wscript.Echo "AutodumpPlus Version " & VERSION
  2527. Wscript.Echo ""
  2528. Wscript.Echo "Purpose:"
  2529. Wscript.Echo "AutodumpPlus automatically generates memory dumps or log files containing"
  2530. Wscript.Echo "scripted debug output usefull for troubleshooting N-tier WinDNA / .Net"
  2531. Wscript.Echo "applications."
  2532. Wscript.Echo ""
  2533. Wscript.Echo "Since WinDNA / .Net applications often encompass multiple, interdependent"
  2534. Wscript.Echo "processes on one or more machines, when troubleshooting an 'application' hang"
  2535. Wscript.Echo "or crash it is often necessary to 'look' at all of the processes at the"
  2536. Wscript.Echo "same time. AutodumpPlus allows you to profile an application that is hanging"
  2537. Wscript.Echo "by taking 'snapshots' (memory dumps, or debug log files) of that application"
  2538. Wscript.Echo "and all of it's processes, all at the same time. Multiple 'snapshots' can"
  2539. Wscript.Echo "then be compared or analyzed to build a history or profile of an application"
  2540. Wscript.Echo "over time."
  2541. Wscript.Echo ""
  2542. Wscript.Echo "In addition to taking 'snapshots' of hung/non-responsive WinDNA / .Net "
  2543. Wscript.Echo "applications, AutodumpPlus can be used to troubleshoot applications that are"
  2544. Wscript.Echo "crashing or throwing unhandled exceptions which can lead to a crash."
  2545. Wscript.Echo ""
  2546. Wscript.Echo "Usage:"
  2547. Wscript.Echo "AutodumpPlus has 3 modes of operation: 'Hang', 'Quick' and 'Crash' mode."
  2548. Wscript.Echo ""
  2549. Wscript.Echo "In 'Hang' mode, AutodumpPlus assumes that a process is hung and it will attach"
  2550. Wscript.Echo "a debugger to the process(s) specified on the command line with either the '-p'"
  2551. Wscript.Echo "or '-pn' or '-iis' switches. After the debugger is attached to the process(s)"
  2552. Wscript.Echo "AutodumpPlus will dump the memory of each process to a .dmp file for later"
  2553. Wscript.Echo "analysis with a debugger (such as WinDBG). In this mode, processes are paused"
  2554. Wscript.Echo "briefly while their memory is being dumped to a file and then resumed."
  2555. Wscript.Echo ""
  2556. Wscript.Echo "In 'Quick' mode AutodumpPlus assumes that a process is hung and it will attach"
  2557. Wscript.ECho "a debugger to the process(s) specified on the command line with either the '-p'"
  2558. Wscript.Echo "or '-pn' or '-iis' switches. After the debugger is attached to the process(s)"
  2559. Wscript.ECho "AutodumpPlus will create text files for each process, containing commonly"
  2560. Wscript.Echo "requested debug information, rather than dumping the entire memory for each"
  2561. Wscript.Echo " process. 'Quick' mode is generally faster than 'Hang' mode, but requires"
  2562. Wscript.Echo "symbols to be installed on the server where AutodumpPlus is running."
  2563. Wscript.Echo ""
  2564. Wscript.Echo "In 'Crash' mode, AutodumpPlus assumes that a process will crash and it will"
  2565. Wscript.ECho "attach a debugger to the process(s) specified on the command line with either"
  2566. Wscript.Echo "the '-p' or '-pn' or '-iis' switches. After the debugger is attached to the"
  2567. Wscript.Echo "process(s) AutodumpPlus will configure the debugger to log 'first chance'"
  2568. Wscript.Echo "exceptions to a text file. When a 'second chance' exception occurs"
  2569. Wscript.Echo "the processes memory is dumped to a .dmp file for analysis"
  2570. Wscript.Echo "with a debugger such as WinDBG. In this mode, a debugger remains attached to"
  2571. Wscript.Echo "the process(s) until the process exits or the debugger is exited by pressing"
  2572. Wscript.Echo "CTRL-C in the minimized debugger window. When the process crashes, or CTRL-C"
  2573. Wscript.Echo "is pressed it will need to be re-started."
  2574. Wscript.Echo ""
  2575. Wscript.Echo "The '-pageheap' switch is only valid in 'crash' mode and should only be used"
  2576. Wscript.Echo "when Pageheap.exe or GFlags.exe has been used to turn on NTDLL's heap"
  2577. Wscript.Echo "debugging options for a specific process, for the purpose of troubleshooting"
  2578. Wscript.Echo "heap corruption issues."
  2579. Wscript.Echo "This switch causes AutodumpPlus to produce a full memory dump when a "
  2580. Wscript.Echo "'debug break' exception is thrown. After the memory dumps is produced, "
  2581. Wscript.Echo "AutodumpPlus exits the debugger which kills the process being monitored."
  2582. Wscript.Echo "These exceptions can be thrown by DLL's that were compiled in debug mode,"
  2583. Wscript.Echo "or if the process being monitored is running with pageheap options enabled."
  2584. Wscript.Echo ""
  2585. Wscript.Echo "The '-quiet' switch can be used to suppress all modal dialog boxes that"
  2586. Wscript.Echo "AutodumpPlus displays. This is usefull if you are running AutodumpPlus"
  2587. Wscript.Echo "inside of a remot command shell. When this switch is used, AutodumpPlus"
  2588. Wscript.Echo "will log information to the event log rather than popping up dialog boxes"
  2589. Wscript.Echo "to the local desktop. Logging to the event log requires Windows Scripting"
  2590. Wscript.Echo "version 5.5 or later."
  2591. Wscript.Echo ""
  2592. Wscript.Echo "The '-o' switch can be used to supply an output directory for AutodumpPlus."
  2593. Wscript.Echo "AutodumpPlus will place all log files and memory dumps in the supplied"
  2594. Wscript.Echo "directory. Long file names should be placed inside of double quotes and"
  2595. Wscript.Echo "UNC paths are supported."
  2596. Wscript.Echo ""
  2597. Wscript.Echo "The '-notify' switch can be used to supply computer name for AutodumpPlus."
  2598. Wscript.Echo "to notify (via NET SEND) when a debugger is finished running."
  2599. Wscript.Echo "A username can be specified but supplying a computer name to notify"
  2600. Wscript.Echo "is generally more reliable."
  2601. Wscript.Echo ""
  2602. Call PrintUsage()
  2603. Wscript.quit 1
  2604. End Sub
  2605. '---------------------------------------------------------------------------------------------
  2606. ' Function: PrintUsage
  2607. ' This is the code used to print the usage information.
  2608. '---------------------------------------------------------------------------------------------
  2609. Sub PrintUsage()
  2610. On Error Resume Next
  2611. If DEBUGGING = TRUE Then
  2612. Wscript.echo ""
  2613. Wscript.echo "-----------------------------------"
  2614. Wscript.echo "In the PrintUsage() function . . ."
  2615. Wscript.echo "-----------------------------------"
  2616. Wscript.echo ""
  2617. End If
  2618. Wscript.Echo "AutodumpPlus " & VERSION & " Usage Information"
  2619. Wscript.Echo "Switches: '-hang', '-quick', '-crash', '-iis', '-p <PID>', '-pn <Process Name>"
  2620. Wscript.echo " '-pageheap', '-quiet', '-o <output directory>, '-notify <target>"
  2621. Wscript.Echo ""
  2622. Wscript.Echo "Required: ('-hang', or '-quick', or '-crash') AND ('-iis' or '-p' or '-pn')"
  2623. Wscript.Echo ""
  2624. Wscript.Echo "Optional: '-pageheap', '-quiet', '-o <outputdir>', '-notify <computer>'"
  2625. Wscript.Echo ""
  2626. Wscript.Echo "Examples: 'ADPlus -hang -iis', Produces memory dumps of IIS and all "
  2627. Wscript.Echo " MTS/COM+ packages currently running."
  2628. Wscript.ECho ""
  2629. Wscript.Echo " 'ADPlus -crash -p 1896', Attaches the debugger to process with PID"
  2630. Wscript.Echo " 1896, and monitors it for 1st and 2nd"
  2631. Wscript.Echo " chance access violations (crashes)."
  2632. Wscript.Echo ""
  2633. Wscript.Echo " 'ADPlus -quick -pn mmc.exe', Attaches the debugger to all instances"
  2634. Wscript.Echo " of MMC.EXE and dumps debug information"
  2635. Wscript.Echo " about these processes to a text file."
  2636. Wscript.Echo ""
  2637. Wscript.Echo " 'ADPlus -?' or 'ADPlus -help': Displays detailed help."
  2638. Wscript.Echo "-------------------------------------------------------------------------------"
  2639. Wscript.Echo "For more information on using AutodumpPlus, please refer to the following KB:"
  2640. Wscript.Echo "http://support.microsoft.com/support/kb/articles/q286/3/50.asp"
  2641. Wscript.quit 1
  2642. End Sub
  2643. '---------------------------------------------------------------------------------------------
  2644. ' Function: FileExists
  2645. ' This is the code used to verify if a file exists.
  2646. '
  2647. '---------------------------------------------------------------------------------------------
  2648. Function FileExists(strFile )
  2649. On Error Resume Next
  2650. If DEBUGGING = TRUE Then
  2651. Wscript.echo ""
  2652. Wscript.echo "-----------------------------------"
  2653. Wscript.echo "In the FileExists() function . . ."
  2654. Wscript.echo "-----------------------------------"
  2655. Wscript.echo ""
  2656. End If
  2657. FileExists = true
  2658. Dim objFileSystem
  2659. Set objFileSystem = CreateObject("Scripting.FileSystemObject")
  2660. FileExists = objFileSystem.FileExists(strFile)
  2661. set objFileSystem = nothing
  2662. End Function
  2663. '---------------------------------------------------------------------------------------------
  2664. ' Function: CreateDirectory()
  2665. ' This is the code used to create a directory on the file system or the network
  2666. ' It checks to make sure you have proper permissions and displays/logs an error
  2667. ' if you don't.
  2668. '---------------------------------------------------------------------------------------------
  2669. Sub CreateDirectory(strDirectory)
  2670. On Error Resume Next
  2671. Err.clear
  2672. Dim objFileSystem
  2673. Dim oFile
  2674. set objFileSystem = CreateObject("Scripting.FileSystemObject")
  2675. Set oFile = objFileSystem.CreateFolder(strDirectory)
  2676. If DEBUGGING = TRUE Then
  2677. Wscript.echo ""
  2678. Wscript.echo "-----------------------------------"
  2679. Wscript.echo "In the CreateDirectory() function . . ."
  2680. Wscript.echo "-----------------------------------"
  2681. Wscript.echo ""
  2682. End If
  2683. If err.number = -2147024784 Then 'The disk is full!
  2684. If DEBUGGING = TRUE Then
  2685. wscript.echo "In CreateDirectory(), Could not create the directory, the error number was: " & err.number & " and the error description was " & err.description
  2686. wscript.echo ""
  2687. End If
  2688. If QuietMode = False Then
  2689. objshell.popup "Could not create the " & strDirectory & " directory because the drive is full. Please free up some disk space and try running AutodumpPlus again!",,"AutodumpPlus",0
  2690. objShell.LogEvent 1, "Could not create the " & strDirectory & " directory because the drive is full. Please free up some disk space and try running AutodumpPlus again!"
  2691. Else
  2692. objShell.LogEvent 1, "Could not create the " & strDirectory & " directory because the drive is full. Please free up some disk space and try running AutodumpPlus again!"
  2693. wscript.echo "Could not create the " & strDirectory & " directory because the drive is full. Please free up some disk space and try running AutodumpPlus again!"
  2694. ErrorsDuringRuntime = True
  2695. End If
  2696. Wscript.Quit 1
  2697. ElseIf err.number = 76 Then 'Specified a subdirectory below a share that does not exist or path with more than one subdirectory that does not exist!
  2698. If DEBUGGING = TRUE Then
  2699. wscript.echo "In CreateDirectory(), Could not create the directory, the error number was: " & err.number
  2700. wscript.echo "In CreateDirectory(), the error description was " & err.description
  2701. End If
  2702. If QuietMode = False Then
  2703. objshell.popup "Could not create the " & strDirectory & " directory. If you are using the '-o' switch and specifying a UNC path, please ensure that the share and any sub-directories below the share you specified actually exist!",,"AutodumpPlus",0
  2704. objShell.LogEvent 1, "Could not create the " & strDirectory & " directory. If you are using the '-o' switch and specifying a UNC path, please ensure that the share and any sub-directories below the share you specified actually exist!"
  2705. Else
  2706. objShell.LogEvent 1, "Could not create the " & strDirectory & " directory. If you are using the '-o' switch and specifying a UNC path, please ensure that the share and any sub-directories below the share you specified actually exist!"
  2707. wscript.echo "Could not create the " & strDirectory & " directory. If you are using the '-o' switch and specifying a UNC path, please ensure that the share and any sub-directories below the share you specified actually exist!"
  2708. ErrorsDuringRuntime = True
  2709. End If
  2710. Wscript.quit 1
  2711. ElseIf err.number = 52 Then 'The share does not exist or can not connect to the UNC path.
  2712. If DEBUGGING = TRUE Then
  2713. wscript.echo "In CreateDirectory(), Could not create the directory, the error number was: " & err.number
  2714. wscript.echo "In CreateDirectory(), the error description was " & err.description
  2715. End If
  2716. If QuietMode = False Then
  2717. objshell.popup "Could not create the " & strDirectory & " directory. If you are using the '-o' switch and specifying a UNC path, please ensure that the UNC path you specified exists and that you are able to connect to it!",,"AutodumpPlus",0
  2718. objShell.LogEvent 1, "Could not create the " & strDirectory & " directory. If you are using the '-o' switch and specifying a UNC path, please ensure that the UNC path you specified exists and that you are able to connect to it!"
  2719. Else
  2720. objShell.LogEvent 1, "Could not create the " & strDirectory & " directory. If you are using the '-o' switch and specifying a UNC path, please ensure that the UNC path you specified exists and that you are able to connect to it!"
  2721. wscript.echo "Could not create the " & strDirectory & " directory. If you are using the '-o' switch and specifying a UNC path, please ensure that the UNC path you specified exists and that you are able to connect to it!"
  2722. ErrorsDuringRuntime = True
  2723. End If
  2724. Wscript.quit 1
  2725. ElseIf err.number <> 0 and err.number <> 58 Then 'Permissions problem
  2726. If DEBUGGING = TRUE Then
  2727. wscript.echo "In CreateDirectory(), Could not create the directory, the error number was: " & err.number & " and the error description was " & err.description
  2728. End If
  2729. If QuietMode = False Then
  2730. objshell.popup "Could not create the " & strDirectory & " directory. Please verify that you have permissions to create this directory and try running AutodumpPlus again!",,"AutodumpPlus",0
  2731. objShell.LogEvent 1, "Could not create the " & strDirectory & " directory. Please verify that you have permissions to create this directory and try running AutodumpPlus again!"
  2732. Else
  2733. objShell.LogEvent 1, "Could not create the " & strDirectory & " directory. Please verify that you have permissions to create this directory and try running AutodumpPlus again!"
  2734. wscript.echo "Could not create the " & strDirectory & " directory. Please verify that you have permissions to create this directory and try running AutodumpPlus again!"
  2735. ErrorsDuringRuntime = True
  2736. End If
  2737. Wscript.quit 1
  2738. End If
  2739. Set oFile = nothing
  2740. Set objFileSystem = nothing
  2741. End Sub
  2742. '---------------------------------------------------------------------------------------------
  2743. ' Function: DeleteDirectory
  2744. ' Code is used to delete a directory. Not sure if its used. May delete it after
  2745. ' a code review.
  2746. '---------------------------------------------------------------------------------------------
  2747. Sub DeleteDirectory(strDirectory)
  2748. On Error Resume Next
  2749. If DEBUGGING = TRUE Then
  2750. Wscript.echo ""
  2751. Wscript.echo "-----------------------------------"
  2752. Wscript.echo "In the DeleteDirectory() function . . ."
  2753. Wscript.echo "-----------------------------------"
  2754. Wscript.echo ""
  2755. End If
  2756. Err.clear
  2757. Dim objFileSystem
  2758. Dim oFile
  2759. set objFileSystem = CreateObject("Scripting.FileSystemObject")
  2760. Set oFile = objFileSystem.DeleteFolder(strDirectory)
  2761. If (err.number <> 0) and (err.number <> 424) Then
  2762. If DEBUGGING = TRUE Then
  2763. Wscript.echo ""
  2764. Wscript.echo "-----------------------------------"
  2765. Wscript.echo "In DeleteDirectory(), after calling objFileSystem.DeleteFolder"
  2766. Wscript.echo "Directory to delete: " & strDirectory
  2767. Wscript.echo "err.number: " & err.number
  2768. Wscript.echo "err.description: " & err.description
  2769. Wscript.echo "-----------------------------------"
  2770. Wscript.echo ""
  2771. End If
  2772. If QuietMode = False Then
  2773. objshell.popup "Could not delete the " & strDirectory & " directory. This error can also occur if you have a file open in the " & strDirectory & " directory or if you don't have sufficient permissions. Please close any open files, check your permissions and try running AutodumpPlus again!",,"AutodumpPlus",0
  2774. Else
  2775. objShell.LogEvent 1, "Could not delete the " & strDirectory & " directory. This error can also occur if you have a file open in the " & strDirectory & " directory or if you don't have sufficient permissions. Please close any open files, check your permissions and try running AutodumpPlus again!"
  2776. wscript.echo "Could not delete the " & strDirectory & " directory. This error can also occur if you have a file open in the " & strDirectory & " directory or if you don't have sufficient permissions. Please close any open files, check your permissions and try running AutodumpPlus again!"
  2777. ErrorsDuringRuntime = True
  2778. End If
  2779. Wscript.quit 1
  2780. End If
  2781. set oFile = nothing
  2782. set objFileSystem = nothing
  2783. Err.clear
  2784. End Sub
  2785. '---------------------------------------------------------------------------------------------
  2786. ' Function: DetectScriptEngine()
  2787. ' This is the used to determine what script engine is currently running the script.
  2788. ' It will prompt the user to switch the default script engine to cscript.exe if
  2789. ' the script is running under wscript.exe.
  2790. '---------------------------------------------------------------------------------------------
  2791. Sub DetectScriptEngine ()
  2792. On Error Resume Next
  2793. Dim ScriptHost
  2794. Dim objShell
  2795. Dim CurrentPathExt
  2796. Dim EnvObject
  2797. Dim RegCScript
  2798. Dim RegPopupType ' This is used to set the pop-up box flags.
  2799. ' I couldn't find the pre-defined names
  2800. RegPopupType = 32 + 4
  2801. set objShell = CreateObject("Wscript.Shell")
  2802. If DEBUGGING = TRUE Then
  2803. Wscript.echo ""
  2804. Wscript.echo "-----------------------------------"
  2805. Wscript.echo "In the DetectScriptEngine() function . . ."
  2806. Wscript.echo "-----------------------------------"
  2807. Wscript.echo ""
  2808. End If
  2809. On Error Resume Next
  2810. ScriptHost = WScript.FullName
  2811. ScriptHost = Right (ScriptHost, Len (ScriptHost) - InStrRev(ScriptHost,"\"))
  2812. If DEBUGGING = TRUE Then
  2813. Wscript.echo "In DetectScriptEngine(), the ScriptHost = " & ScriptHost
  2814. Wscript.echo ""
  2815. End If
  2816. If (UCase (ScriptHost) = "WSCRIPT.EXE") Then
  2817. ' Create a pop-up box and ask if they want to register cscript as the default host.
  2818. Set objShell = WScript.CreateObject ("WScript.Shell")
  2819. ' -1 is the time to wait. 0 means wait forever.
  2820. If QuietMode = False Then
  2821. RegCScript = objShell.PopUp ("Wscript.exe is currently your default script interpreter. This script requires the Cscript.exe script interpreter to work properly. Would you like to register Cscript.exe as your default script interpreter for VBscript?", 0, "Register Cscript.exe as default script interpreter?", RegPopupType)
  2822. Else 'Running in Quiet mode, assume the user would WANT to change their script default script interpreter if they were prompted.
  2823. RegCscript = 6
  2824. End If
  2825. If (Err.Number <> 0) Then
  2826. ReportError ()
  2827. WScript.Echo "To run this script using the CScript.exe script interpreter, type: ""CScript.exe " & WScript.ScriptName & """"
  2828. WScript.Quit 1
  2829. End If
  2830. ' Check to see if the user pressed yes or no. Yes is 6, no is 7
  2831. If (RegCScript = 6) Then
  2832. objShell.RegWrite "HKEY_CLASSES_ROOT\VBSFile\Shell\Open\Command\", "%WINDIR%\System32\CScript.exe //nologo ""%1"" %*", "REG_EXPAND_SZ"
  2833. objShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VBSFile\Shell\Open\Command\", "%WINDIR%\System32\CScript.exe //nologo ""%1"" %*", "REG_EXPAND_SZ"
  2834. ' Check if PathExt already existed
  2835. CurrentPathExt = objShell.RegRead ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PATHEXT")
  2836. if Err.Number = &h80070002 Then
  2837. Err.Clear
  2838. Set EnvObject = objShell.Environment ("PROCESS")
  2839. CurrentPathExt = EnvObject.Item ("PATHEXT")
  2840. End If
  2841. objShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PATHEXT", CurrentPathExt & ";.VBS", "REG_SZ"
  2842. If (Err.Number <> 0) Then
  2843. If QuietMode = True Then
  2844. objShell.Logevent 1, "Error trying to write the registry settings! The error number was: " & Err.Number & " and the error description was: " & err.description
  2845. Wscript.Quit (Err.Number)
  2846. Else
  2847. Wscript.echo "Error trying to write the registry settings! The error number was: " & Err.Number & " and the error description was: " & err.description
  2848. WScript.Quit (Err.Number)
  2849. End If
  2850. Else
  2851. If QuietMode = True Then
  2852. objShell.Logevent 0, "Since AutodumpPlus is running in 'Quiet' mode, the default script interpreter was automatically changed to CScript to ensure compatibility with this script. Autodump will now open a new command shell window and run ADPlus.vbs again with the argument passsed in on the command line. To change the default script engine back to Wscript, type 'wscript.exe //h:wscript' in a command shell."
  2853. Else
  2854. WScript.Echo "Successfully registered Cscript.exe as the default script interpreter! To change the default script engine back to Wscript, type 'wscript.exe //h:wscript' in a command shell."
  2855. End If
  2856. End If
  2857. Else 'The user does not want the script engine changed and didn't use the '-quiet' switch.
  2858. WScript.Echo "The default script interpreter was NOT changed to CScript. Press 'OK' to continue running AutodumpPlus with the Cscript.exe script interpreter. NOTE: AutodumpPlus will now open a new command shell to run ADPlus.vbs with the CScript script engine. A new command shell will be opened each time AutoDumpPlus is run until the default script interpreter is changed to Cscript.exe."
  2859. End If
  2860. Dim ProcString
  2861. Dim ArgIndex
  2862. Dim ArgObj
  2863. Dim Result
  2864. Dim StrShell
  2865. ProcString = "Cscript //nologo " & Chr(34) & WScript.ScriptFullName & Chr(34)
  2866. If DEBUGGING = TRUE Then
  2867. Wscript.echo "In DetectScriptEngine(), the ProcString = " & ProcString
  2868. Wscript.echo ""
  2869. End If
  2870. Set ArgObj = WScript.Arguments
  2871. If DEBUGGING = TRUE Then
  2872. Wscript.echo "In DetectScriptEngine(), there were: " & ArgObj.Count & " arguments specified on the command line."
  2873. Wscript.echo ""
  2874. End If
  2875. For ArgIndex = 0 To ArgObj.Count - 1
  2876. ProcString = ProcString & " " & ArgObj.Item (ArgIndex)
  2877. Next
  2878. strShell = "cmd /k " & ProcString
  2879. If DEBUGGING = TRUE Then
  2880. Wscript.echo "In DetectScriptEngine(), about to run the script with the following strShell: " & strShell
  2881. Wscript.echo ""
  2882. End If
  2883. objShell.Run strShell,ACTIVATE_AND_DISPLAY,TRUE
  2884. WScript.Quit 1
  2885. End If
  2886. End Sub
  2887. '---------------------------------------------------------------------------------------------
  2888. ' Function: DetectOSVersion
  2889. ' This function is responsible for determining which operating system we are
  2890. ' running on and to ensure its NT 4.0 SP4 or higher.
  2891. '---------------------------------------------------------------------------------------------
  2892. Sub DetectOSVersion()
  2893. On Error Resume Next
  2894. If DEBUGGING = TRUE Then
  2895. Wscript.echo ""
  2896. Wscript.echo "-----------------------------------"
  2897. Wscript.echo "In the DetectOSVersion() function . . ."
  2898. Wscript.echo "-----------------------------------"
  2899. Wscript.echo ""
  2900. End If
  2901. Dim objShell
  2902. Dim SPLevel
  2903. Dim Temp, cnt
  2904. err.clear
  2905. Set objShell = CreateObject("Wscript.Shell")
  2906. OSVer = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion")
  2907. OSBuildNumber = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentBuildNumber")
  2908. If (Err.Number <> 0) Then
  2909. If QuietMode = True Then
  2910. objShell.Logevent 1, "There was an error trying to read the OS version information from the registry! The error number was: " & Err.Number & " and the error description was: " & err.description & " Please check the permissions on the key show and try running AutodumpPlus again."
  2911. Wscript.Quit (Err.Number)
  2912. Else
  2913. objShell.Popup "There was an error trying to read the OS version information from the registry! The error number was: " & Err.Number & " and the error description was: " & err.description & " Please check the permissions on the key show and try running AutodumpPlus again.",,"AutodumpPlus",0
  2914. WScript.Quit (Err.Number)
  2915. End If
  2916. Else
  2917. If DEBUGGING = TRUE Then
  2918. Wscript.echo "In DetectOSVersion(), after querying the registry for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion: "
  2919. Wscript.echo "In DetectOSVersion(), the OSVer = " & OSVer
  2920. Wscript.echo "In DetectOSVersion(), the OSBuildNumber = " & OSBuildNumber
  2921. Wscript.echo ""
  2922. End If
  2923. If OSVer = "4.0" then
  2924. SPLevel = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CSDVersion")
  2925. If DEBUGGING = TRUE Then
  2926. Wscript.echo "In DetectOSVersin(), SPLevel = " & SPLevel
  2927. End If
  2928. Temp = Split(SPLevel,",")
  2929. If UBound(Temp) <> 0 Then 'The customer must not have a released service pack, make a best effor to get the version.
  2930. Wscript.echo " Temp: " & Temp(0) & Temp(1)
  2931. For cnt = 0 to UBound(Temp)
  2932. If instr(1,Temp(cnt),"sp",1) <> 0 then
  2933. SPLevel = Right(Temp(cnt), 1)
  2934. Wscript.echo "SPlevel = " & SPlevel
  2935. exit for
  2936. else
  2937. 'continue to the next string in the list.....
  2938. End if
  2939. Next
  2940. Else
  2941. 'Customer has a released version of the service pack, get the SP number.
  2942. SPLevel = Right(SPLevel, 1)
  2943. End If
  2944. If SPLevel < 4 then
  2945. Wscript.echo "Autodump.vbs requires NT 4.0 Service Pack 4 or higher, or Windows 2000 in order to run."
  2946. Wscript.quit 1
  2947. end if
  2948. End if
  2949. End If
  2950. End sub
  2951. '---------------------------------------------------------------------------------------------
  2952. ' Function: DetectIISVersion
  2953. ' This function is responsible for determining which version of IIS we are
  2954. ' running on. Since the '-iis' switch does not work on IIS 3.0, AutodumpPlus
  2955. ' checks for IIS 3.0 or lower in the registry and does not allow the switch to be
  2956. ' used. If the version of IIS is greater than 5.x, AutodumpPlus also does not
  2957. ' allow the switch to be used as IIS 6.0 was not tested in time for this release.
  2958. '---------------------------------------------------------------------------------------------
  2959. Sub DetectIISVersion()
  2960. On Error Resume Next
  2961. If DEBUGGING = TRUE Then
  2962. Wscript.echo ""
  2963. Wscript.echo "-----------------------------------"
  2964. Wscript.echo "In the DetectIISVersion() function . . ."
  2965. Wscript.echo "-----------------------------------"
  2966. Wscript.echo ""
  2967. End If
  2968. On Error Resume Next
  2969. Dim objShell
  2970. Dim AccessDeniedIIS4
  2971. Dim AccessDeniedIIS3
  2972. Dim NotFound
  2973. Dim Installed
  2974. Dim IIS3
  2975. Dim IIS4
  2976. Dim IIS4Key
  2977. Dim IIS3Key
  2978. NotFound = True
  2979. AccessDeniedIIS4 = False
  2980. AccessDeniedIIS3 = False
  2981. IIS3 = False
  2982. IIS4 = False
  2983. Installed = False
  2984. IIS4Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\VersionString"
  2985. IIS3Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Inetsrv\CurrentVersion\ServiceName"
  2986. Set objShell = CreateObject("Wscript.Shell")
  2987. 'Check the IIS 4.0 and 5.x registry key to see if the user is running IIS 4.0 or 5.0
  2988. IISVer = objShell.RegRead(IIS4Key)
  2989. If err.number = -2147024894 Then 'The key was not found, check for IIS 3.0
  2990. If DEBUGGING = TRUE Then
  2991. Wscript.echo "In DetectIISVersion(), after querying the registry for: " & IIS4Key
  2992. Wscript.echo "In DetectOSVersion(), the key was not found, checking for IIS 3.0"
  2993. Wscript.echo ""
  2994. End If
  2995. err.clear
  2996. IISVer = objShell.RegRead(IIS3Key)
  2997. If err.number = -2147024891 Then
  2998. 'AutodumpPlus doesn't have permissions to read IIS 3.0's registry version key.
  2999. If DEBUGGING = TRUE Then
  3000. Wscript.echo "In DetectIISVersion(), after querying the registry for: " & IIS3Key
  3001. Wscript.echo "In DetectOSVersion(), access was denied trying to query the key."
  3002. Wscript.echo ""
  3003. End If
  3004. AccessDeniedIIS3 = True
  3005. ElseIf err.number = -2147024894 Then
  3006. 'IIS 3.0 or higher is not installed.
  3007. If DEBUGGING = TRUE Then
  3008. Wscript.echo "In DetectIISVersion(), after querying the registry for: " & IIS3Key
  3009. Wscript.echo "In DetectIISVersion(), IIS 3.0, 4.0, or 5.0 were not detected. No IIS Key's exist in the registry."
  3010. Wscript.echo ""
  3011. End If
  3012. IISVer = "Not found"
  3013. Notfound = True
  3014. Installed = False
  3015. ElseIf err.number = 0 Then
  3016. 'IIS 3.0 is installed and the version key can be read.
  3017. If DEBUGGING = TRUE Then
  3018. Wscript.echo "In DetectIISVersion(), after querying the registry for: " & IIS3Key
  3019. Wscript.echo "In DetectIISVersion(), the IIS3Key exists and can be read. Running either IIS 2.0 or 3.0."
  3020. Wscript.echo ""
  3021. End If
  3022. Installed = True
  3023. IIS3 = True
  3024. AccessDeniedIIS3 = False
  3025. Else
  3026. 'Some other error has occurred accessing the version key's. Display an error and exit gracefully.
  3027. If DEBUGGING = TRUE Then
  3028. Wscript.echo "In DetectIISVersion(), after querying the registry for: " & IIS3Key
  3029. Wscript.echo "In DetectIISVersion(), There was an unknown problem accessing the registry."
  3030. Wscript.echo ""
  3031. End If
  3032. Wscript.echo "There was an error reading the registry. The error number was: " & err.number & " and the error description was: " & err.description
  3033. Wscript.quit (err.number)
  3034. End If
  3035. ElseIf err.number = -2147024891 Then 'They are running IIS 4.0 or 5.x (the key was found) but they don't have permissions
  3036. 'AutodumpPlus doesn't have the proper permissions to read either the IIS 4.0 or 5.x registry keys but they exist.
  3037. If DEBUGGING = TRUE Then
  3038. Wscript.echo "In DetectIISVersion(), after querying the registry for: " & IIS4Key
  3039. Wscript.echo "In DetectIISVersion(), access was denied trying to query the key."
  3040. Wscript.echo ""
  3041. End If
  3042. AccessDeniedIIS4 = True
  3043. ElseIf err.number = 0 Then
  3044. If InStr(IISVer,"4") <> 0 or InStr(IISVer,"5") <>0 or InStr(IISVer,"6") <>0 Then
  3045. 'IIS 4.0, 5.x, or 6.0 is installed and AutodumpPlus can access the version key.
  3046. IIS4 = True
  3047. Installed = True
  3048. If DEBUGGING = TRUE Then
  3049. Wscript.echo "In DetectIISVersion(), after querying the registry for: " & IIS4Key
  3050. Wscript.echo "In DetectIISVersion(), IIS 4.0, 5.x, or 6.0 was found."
  3051. Wscript.echo ""
  3052. End If
  3053. Else
  3054. 'AutodumpPlus has detected a newer version of IIS that has not been tested. Display an error and disable the '-iis' switch to be safe.
  3055. If DEBUGGING = TRUE Then
  3056. Wscript.echo "In DetectIISVersion(), after querying the registry for: " & IIS4Key
  3057. Wscript.echo "In DetectIISVersion(), ADPlus has detected an unsupported version of IIS (possibly IIS 7.0 or higher)."
  3058. Wscript.echo ""
  3059. End If
  3060. If QuietMode = False Then
  3061. objShell.popup "You appear to have IIS " & IISVer & " installed. This has not been tested with the '-iis' switch. Please run AutodumpPlus again, without the '-iis' switch.",,"AutodumpPlus",0
  3062. Wscript.quit
  3063. Else
  3064. wscript.echo "You appear to have IIS " & IISVer & " installed. This has not been tested with the '-iis' switch. Please run AutodumpPlus again, without the '-iis' switch."
  3065. objShell.logevent 1, "You appear to have IIS " & IISVer & " installed. This has not been tested with the '-iis' switch. Please run AutodumpPlus again, without the '-iis' switch."
  3066. Wscript.quit
  3067. End If
  3068. End If
  3069. Else
  3070. If DEBUGGING = TRUE Then
  3071. Wscript.echo "In DetectIISVersion(), after querying the registry for: " & IIS3Key
  3072. Wscript.echo "In DetectIISVersion(), There was an unknown problem accessing the registry."
  3073. Wscript.echo ""
  3074. End If
  3075. Wscript.echo "There was an error reading the registry"
  3076. Wscript.quit (err.number)
  3077. End If
  3078. If AccessDeniedIIS3 = True and IISMode = True Then
  3079. If QuietMode = False Then
  3080. objShell.popup "You appear to be running IIS 3.0 or lower, however AutodumpPlus had trouble verifying the IIS version in the registry at the following location: '" & IIS3Key & "', because of a permissions problem. The '-IIS' switch only works on IIS 4.0 or higher. If you are trying to monitor IIS 2.0 or IIS 3.0 please using the '-pn' switch to monitor inetinfo.exe.",,"AutodumpPlus",0
  3081. Wscript.quit 1
  3082. Else
  3083. wscript.echo "You appear to be running IIS 3.0 or lower, however AutodumpPlus had trouble verifying the IIS version in the registry at the following location: '" & IIS3Key & "', because of a permissions problem. The '-IIS' switch only works on IIS 4.0 or higher. If you are trying to monitor IIS 2.0 or IIS 3.0 please using the '-pn' switch to monitor inetinfo.exe."
  3084. objShell.LogEvent 1, "You appear to be running IIS 3.0 or lower, however AutodumpPlus had trouble verifying the IIS version in the registry at the following location: '" & IIS3Key & "', because of a permissions problem. The '-IIS' switch only works on IIS 4.0 or higher. If you are trying to monitor IIS 2.0 or IIS 3.0 please using the '-pn' switch to monitor inetinfo.exe."
  3085. Wscript.quit 1
  3086. End If
  3087. ElseIf AccessDeniedIIS4 = True and IISMode = True Then
  3088. If QuietMode = False Then
  3089. objShell.popup "You appear to be running IIS 4.0 or higher, however AutodumpPlus had trouble verifying the IIS version in the registry at the following location: '" & IIS4Key & "', because of a permissions problem. The '-IIS' switch only works on IIS 4.0 or higher. If you are trying to monitor IIS 2.0 or IIS 3.0 please using the '-pn' switch to monitor inetinfo.exe.",,"AutodumpPlus",0
  3090. Wscript.quit 1
  3091. Else
  3092. wscript.echo "You appear to be running IIS 4.0 or higher, however AutodumpPlus had trouble verifying the IIS version in the registry at the following location: '" & IIS4Key & "', because of a permissions problem. The '-IIS' switch only works on IIS 4.0 or higher. If you are trying to monitor IIS 2.0 or IIS 3.0 please using the '-pn' switch to monitor inetinfo.exe."
  3093. objShell.logevent 1, "You appear to be running IIS 4.0 or higher, however AutodumpPlus had trouble verifying the IIS version in the registry at the following location: '" & IIS4Key & "', because of a permissions problem. The '-IIS' switch only works on IIS 4.0 or higher. If you are trying to monitor IIS 2.0 or IIS 3.0 please using the '-pn' switch to monitor inetinfo.exe."
  3094. Wscript.quit 1
  3095. End If
  3096. ElseIf IIS3 = True AND IISMode = True Then
  3097. If QuietMode = False then
  3098. objShell.popup "You have specified the '-iis' switch, however you appear to be running " & IISVer & ". The '-iis' switch only works with IIS 4.0 and higher.",,"Autodump",0
  3099. Wscript.quit 1
  3100. Else
  3101. wscript.echo "You have specified the '-iis' switch, however you appear to be running " & IISVer & ". The '-iis' switch only works with IIS 4.0 and higher."
  3102. objShell.logevent 1, "You have specified the '-iis' switch, however you appear to be running " & IISVer & ". The '-iis' switch only works with IIS 4.0 and higher."
  3103. Wscript.quit 1
  3104. End if
  3105. ElseIf Installed = False AND IISMode = True Then
  3106. If QuietMode = False then
  3107. objShell.popup "You have specified the '-iis' switch, however you do not appear to be running a supported version of IIS. The '-iis' switch only works with IIS 4.0 and higher.",,"Autodump",0
  3108. Wscript.quit 1
  3109. Else
  3110. wscript.echo "You have specified the '-iis' switch, however you do not appear to be running a supported version of IIS. The '-iis' switch only works with IIS 4.0 and higher."
  3111. objShell.logevent 1, "You have specified the '-iis' switch, however you do not appear to be running a supported version of IIS. The '-iis' switch only works with IIS 4.0 and higher."
  3112. Wscript.quit 1
  3113. End if
  3114. End If
  3115. Set objShell = nothing
  3116. End sub