@Echo Off
SetLocal EnableExtensions
set MY_VAR=""
For /F "Tokens=1,* Delims==" %%G In ('
wmic Process Where
"Name = 'w3wp.exe' And CommandLine Like '%%w3wp.exe%%SharePoint%%-h%%config%%'"
Get CommandLine /Format:List 2^>NUL') Do For /F "Tokens=*" %%I In ("%%H"
) Do (
echo %%I
set MY_VAR=%%I
echo %MY_VAR%
)
In the above example, the program outputs the following output:
c:\windows\system32\inetsrv\w3wp.exe -ap "SharePoint Central Administration v4" -v "v4.0" -l "webengine4.dll" -a \\.\pipe\iisipm3a5c9a69-c047-4ec4-aee3-f02e7358acca -h "C:\inetpub\temp\apppools\SharePoint Central Administration v4\SharePoint Central Administration v4.config" -w "" -m 0
""
I cannot understand why the value of MY_VAR is not equal to %%I.