Force-quit a Shell (Windows)

That would definitely explain what you’re seeing. Until all of the bits of the chain exit, the shell is effectively still running. Scrub creating a feedback report…

At least MS has a hot fix available…

I’m going to install any updates as of today, restart, try again, and if still failure, then try the hotfix, and report back.

Unfortunately neither worked, and I am discovering a multitude of users via google that also have problems with this.

The only solution I can see is to force quit the applications… would you happen to know where to point me as to how to figure out what the PID of the processes are and force-quit them problematically?

Even the hotfix didn’t resolve this?

Quick and dirty hunch : call your shell from a threaded batch script. Then the batch script would be the owner of the processes, right ?

Pass the Shell.PID property to this method (Win32 only):

Function KillProcess(ProcessID As Integer, ExitCode As Integer = 0) As Integer
  Declare Function OpenProcess Lib "Kernel32" (DesiredAccess As Integer, InheritHandle As Boolean, ProcessId As Integer) As Integer
  Declare Function TerminateProcess Lib "Kernel32" (ProcessHandle As Integer, ExitCode As Integer) As Boolean
  Declare Function CloseHandle Lib "Kernel32" (Handle As Integer) As Boolean
  Declare Function GetLastError Lib "Kernel32" () As Integer
  Const PROCESS_TERMINATE = &h1
  
  Dim pHandle, lasterr As Integer
  pHandle = OpenProcess(PROCESS_TERMINATE, False, ProcessID)
  lasterr = GetLastError()
  
  If lasterr = 0 And TerminateProcess(pHandle, ExitCode) Then
     lasterr - GetLastError()
    Call CloseHandle(pHandle)
  End If
  
  Return lasterr
End Function

Doug,

Did you try the following (from: http://support.microsoft.com/kb/2815716):

To Configure a timeout value for SPLWow64.exe

Click Start, and then click Run.
Type regedit, and then click OK.
Locate and then right-click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print
Point to New, and then click DWORD Value.
Type SplWOW64TimeOutSeconds as the registry entry name, and then press Enter.
Double-click the SplWOW64TimeOutSeconds entry that you created in step 4.
Enter a value in the Value data box, and then click OK.

IMO terminating the process would be a last resort option.

[quote=44910:@Andrew Lambert]

lasterr - GetLastError() [/quote]

Should be:

     lasterr = GetLastError()

@Andrew Lambert - that doesn’t work for 64 bit OS, right?

It works on 32 and 64 bit Windows. However, it seems that Shell.PID doesn’t actually return a PID on Windows, so you’ll have to get the ID number someplace else (look at the Windows Functionality Suite’s process handling code for examples of finding a process ID.)

That’s odd, I do seem to get a valid PID from the shell instance. I’m on Windows 7x64, Xojo 2013r3.3.

I don’t, using the same OS and IDE version. I get a number that doesn’t correspond to any running process or thread ID. screenshot.

Correction: I’m using Xojo 3.2. Updating now.

Just tried 3.3, same behavior. I made this feedback case so as not to hijack @Doug Craig’ thread: <https://xojo.com/issue/30771>

Andrew,

you get the process handle not the process ID (PID).
The property name is very confusing…

[quote=45968:@Maurizio Rossi]Andrew,

you get the process handle not the process ID (PID).
The property name is very confusing…[/quote]
What kind of process handle? Can I use it like a handle from OpenProcess?

Apparently I can!

Function KillShell(sh As Shell) As Integer
  Declare Function TerminateProcess Lib "Kernel32" (ProcessHandle As Integer, ExitCode As Integer) As Boolean
  Declare Function GetLastError Lib "Kernel32" () As Integer
  If TerminateProcess(sh.PID, 0) Then
    Return GetLastError()
  End If
End Function

Yes, exactly this way,
You can use the handle as a parameter to the GetProcessId() Win32 function to get the process ID (PID).