Jaafar Tribak
Well-known Member
- Joined
- Dec 5, 2002
- Messages
- 9,806
- Office Version
- 2016
- Platform
- Windows
Hi,
I am shelling a new folder window in order to display the C:\ root directory as follows :
A new explorer window is displayed as expected and a PID number is returned however when I pass the PID to the Shell function in the second call in order to terminate the explorer process and close the explorer window, the explorer window remains and never closes.
It looks as if the PID returned by the first shell call is "incorrect" (In fact, I can see in the Task Manager a different PID for the newly opened explorer)
I have tried other methods for opening explorer such as with the ShellExecute API, and Shell Automation but the returned PID is still not working.
Any thoughts anyone ?
Thank you.
I am shelling a new folder window in order to display the C:\ root directory as follows :
Code:
Sub Test()
Dim vPid As Variant
vPid = Shell("explorer.exe """ & "C:\" & "", vbNormalFocus)
MsgBox vPid
Call Shell("TaskKill /F /PID " & CStr(vPid), vbHide)
End Sub
A new explorer window is displayed as expected and a PID number is returned however when I pass the PID to the Shell function in the second call in order to terminate the explorer process and close the explorer window, the explorer window remains and never closes.
It looks as if the PID returned by the first shell call is "incorrect" (In fact, I can see in the Task Manager a different PID for the newly opened explorer)
I have tried other methods for opening explorer such as with the ShellExecute API, and Shell Automation but the returned PID is still not working.
Any thoughts anyone ?
Thank you.