FOR /F "tokens=2" %I in ('TASKLIST /NH /FI "WINDOWTITLE eq testwindow"' ) DO SET PID=%I
That code might work OK as a command typed in at the prompt, but as a line in a batch script, it needs the percent signs doubled up so that %I becomes %%I. This is a fundamental part of Windows command scripting that has clearly passed you by.
You got unlucky in that you had to contend with Geek-9PM who is getting increasingly erratic, (but cannot help it) and also DonnaDay (who is really Bill Richardson, a malicious troll, and does it on purpose). I am on vacation in Andalucia, Spain right now so naturally this part of the forum has gone downhill rapidly. A couple of points...
1. The command prompt environment in Windows NT family operating systems from Windows 2000 onwards that you are clearly using, is most definitely not "DOS". There was a command line operating system called "MS-DOS" which was last updated around 1992. This is not it.
2. The 1990s called. They want their "...not" back.
3. If you are unsatisfied, please contact the Computerhope finance department and reclaim your membership fee and posting charges.