Using WMIC to get a specific Process ID


i'm trying write batch file grab processid of specific w3wp.exe process. there multiple w3wp's running on server, need add clause right one. can part...so, i've got far:

for /f %%a in ('wmic process "commandline '%%prod%%'and name='w3wp.exe'" processid ') echo %%a

the problem output contains literal column heading 'process id' along numeric value process id i'm looking for. want actual pid, can store in variable , use further down in batch file.

any appreciated.

thank you.

if powershell solution this:

get-process w3wp |  select id | ft -autosize

or can use: stop-service w3wp

but if want batch file, guess kinda hard..

batch file:

 for /f "tokens=2" %%i in ('tasklist ^| find "w3wp.exe"') set pid=%%i


every second counts..make use of it. disclaimer: posting provided no warranties or guarantees , confers no rights.
it stuff quick bytes




Windows Server  >  Windows Server General Forum



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL