I was doing some investigation on a customer site and needed to use adplus.vbs to take process dumps, however I was forever getting the above error and couldn’t for a while work it out. I thought I must have typed in the wrong process id, but after checking and double checking I wasn’t, so I headed off for my favourite search engine and found this post by Jon Robbins which was close but not quite right. However it gave me the idea I needed to track down the issue.

Looking at the current version of adplus.vbs, the code that parses the output of TLIST was as follows…

' removing the first four chars; they are always "0 32"

' (it used to be only 2 chars - it didn't have the 32) strAux = Right(strAux, StrLength - 4)

However – this doesn’t work under terminal services as the output you’ll be parsing is something like the following :-

12 32 9612 Blah.exe          

     Command Line: "C:\Program Files\Whatever\Blah.exe"

 0 32 6508 dllhost.exe     Svcs:  COMSysApp  Mts:   System Application

     Command Line: C:\WINDOWS\system32\dllhost.exe /Processid:{02D4B3F1-FD88-11D1-960D-00805FC79235}

13 32 11544 AcroRd32.exe   

     Command Line: "C:\Program Files\Adobe\Reader\AcroRd32.exe"  "C:\Jabba\Yoda_Rules.pdf"

 4 32 10816 iexplore.exe    Title: Install Debugging Tools for Windows 32-bit Version – Microsoft

Internet Explorer

     Command Line: "C:\Program Files\Internet Explorer\iexplore.exe"

 0 32 2596 msiexec.exe     Svcs:  MSIServer

     Command Line: C:\WINDOWS\system32\msiexec.exe /V

Now, you might have noticed the ‘12 32 9612’ entry or the ‘13 32 11544’ entry. Chopping 4 characters from the front of these will yield a process ID of ‘2’ with the current script which isn’t correct. At best you’ll get an error, at worst you’ll get a dump for process ID 2 and that’s not the one you’re after.

To fix this you’ll need to modify your version of adplus.vbs. I’ve raised the bug internally and understand it’ll be fixed in the next release of the debugging tools for windows package. To modify the file do the following :-

(1) Go to line 2190 – the comment “removing the initial part we dont need [group] 0 32”

(2) Comment out everything from there to line 2208, “arrAux= split(strAux," ",-1,1)”

(3) Paste in the following code

'If this works it was modified by Morgan Skinner.
'If not I don't know who modified it.
arrAux = Split (LTrim(strAux))

If InStr(arrAux(0), "[") = 1 Then
  'If item [0] begins with '[' then we're on Windows 7+ so are 
  'interested in everything from item 3 and onwards
  k = InStr(strAux, arrAux(3))
Else
  'If not we're interested in everything from item 2 onwards
  k = InStr(strAux, arrAux(2))
End If

'I now have the position of the process ID string in the strAux string.
'Use that to cobble up the arrAux variable to what's expected

strAux = Right(strAux,Len(strAux)-(k-1))
arrAux = Split(strAux)

What you should end up with is something that looks like the following :-

' removing the initial part we dont need [group] 0 32

' [group] was introduced in win7

 

'            strAux = LTrim(strAux)

'            StrLength = Len(strAux)

 

'            If instr(strAux, "[") = 1 then

'                k = instr(strAux, "]")

'                strAux = Right(strAux, StrLength - k)

'                strAux = LTrim(strAux)

'                StrLength = Len(strAux)

'            End If

 

'            ' removing the first four chars; they are always "0 32"

'            ' (it used to be only 2 chars - it didn't have the 32)

'            strAux = Right(strAux, StrLength - 4)

'            'strAux = Right(strAux, StrLength - 2)

'            strAux = LTrim(strAux)

 

'            arrAux= split(strAux," ",-1,1)

 

 

'*** If this works it was modified by Morgan Skinner.

'*** If not I don't know who modified it.

arrAux = Split (LTrim(strAux))

 

If InStr(arrAux(0), "[") = 1 Then

  'If item [0] begins with '[' then we're on Windows 7+ so are

  'interested in everything from item 3 and onwards

  k = InStr(strAux, arrAux(3))

Else

  'If not we're interested in everything from item 2 onwards

  k = InStr(strAux, arrAux(2))

End If

 

'I now have the position of the process ID string in the strAux string.

'Use that to cobble up the arrAux variable to what's expected

 

strAux = Right(strAux,Len(strAux)-(k-1))

arrAux = Split(strAux)

'*** End modifications

 

set g_CurrentProcesses(PCount) = new RunningProcess

All of the new code is in bold.

This seems to work OK on my system – but as ever your mileage may vary.

Originally posted by Morgan Skinner on May 5th 2009 here.