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
Post a Comment