I look at this for about 2 hours and I think there is a way to do this, but it requires more details on how Windows handles iexplore.exe for PID ...
I have a working version of the batch file that I wrote, and you will get what you want, BUT , only if its first and last Internet Explorer windows are open.
For some reason, I cannot force the PID to change when opening new browsers, but I can get the results if there is no window open (obviously, because there is no PID)
Anyway, this is what I have ... you should be able to run this on your system, and it will tell you that there are no differences, and this may lead to results if your default browser is Firefox or Chrome or something else ... you just need to make changes to what I provide.
@echo off IF EXIST c:\temp\pshell.txt del c:\temp\pshell.txt IF EXIST C:\temp\PID1.txt del C:\temp\PID1.txt IF EXIST C:\temp\PID2.txt del C:\temp\PID2.txt IF EXIST C:\temp\PowerFormat.txt del C:\temp\PowerFormat.txt powershell.exe Get-Process iexplore>C:\temp\pshell.txt FOR /F "skip=3 tokens=7 delims= " %%1 IN ( c:\temp\pshell.txt ) DO @echo %%1>> C:\temp\PID1.txt start "title" "www.google.com" powershell.exe Get-Process iexplore>C:\temp\pshell.txt FOR /F "skip=3 tokens=7 delims= " %%2 IN ( c:\temp\pshell.txt ) DO @echo %%2>> C:\temp\PID2.txt FC /L c:\temp\pid1.txt c:\temp\pid2.txt> C:\temp\FileComparison.txt FOR /F "tokens=7 delims=" %%3 IN (c:\temp\FileComparison.txt) DO @echo %%3>C:\temp\DiffPID.txt FINDSTR "FC: no differences encountered" c:\temp\FileComparison.txt IF '%ERRORLEVEL%'=='0' del C:\temp\FileComparison.txt & echo.No PID Found IF NOT '%ERRORLEVEL%'=='0' type c:\temp\FileComparison.txt pause exit
Let me know if this helps ...
rud3y
source share