Leaked source code of windows server 2003
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.

3972 lines
241 KiB

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