You are not logged in.

#1 05 Jun 2017 09:23

Andrew.au
Member
Registered: 21 May 2017
Posts: 5

FOR /F loop runs within a temporary instance of cmd.exe

This is probably well-known to batch gurus

C:\Users\Andrew>tasklist /FI "username eq %username%" | findstr /I cmd.exe
cmd.exe                      14836 Console                    1      3,020 K

C:\Users\Andrew>for /F "delims=" %A in ('tasklist /FI "username eq %username%" ^| findstr /I cmd.exe') do @echo %A
cmd.exe                      14836 Console                    1      3,068 K
cmd.exe                       8084 Console                    1      2,660 K

Offline

#2 05 Jun 2017 21:26

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: FOR /F loop runs within a temporary instance of cmd.exe

Also that second copy of CMD will inherit any variables you have set, so I think it is a COPY of the current CMD instance rather than a completely fresh instantiation.

Offline

Board footer

Powered by