Answered by:
WMIC get Executable path in batch file

Question
-
Hi,
I would like to get a execution path of a process using batch file. I wrote,
FOR /F "usebackq skip=1 tokens=* delims==" %%f IN (`wmic process where "ProcessID=8000" get ExecutablePath`) DO echo %%f
This command gives the execution path. But i cant set the value in a variable. Set command also fails here.
Please anyone help me.
- Moved by Bill_Stewart Friday, November 28, 2014 5:05 PM Unanswerable drive-by question
Thursday, October 9, 2014 9:47 AM
Answers
All replies
-
Use PowerShell:
$expath=(Get-WmiObject Win32_Process -filter 'Handle=8000').ExecutablePath
¯\_(ツ)_/¯
Thursday, October 9, 2014 2:29 PM -
Hi,
I would like to get a execution path of a process using batch file. I wrote,
FOR /F "usebackq skip=1 tokens=* delims==" %%f IN (`wmic process where "ProcessID=8000" get ExecutablePath`) DO echo %%f
This command gives the execution path. But i cant set the value in a variable. Set command also fails here.
Please anyone help me.
Here you go:
@echo off
FOR /F "delims==" %%f IN ('wmic process where "ProcessID=3940" get ExecutablePath ^| find "\"') do set Exe=%%f
echo %Exe%
- Proposed as answer by Frederik Long Friday, October 10, 2014 8:48 AM
Thursday, October 9, 2014 5:37 PM -
wmic:root\cli>process
ERROR:
Description = Exception occurred.what is the problem with this??
Can anyone tell me..!
- Edited by Prznt Friday, October 10, 2014 11:23 AM
Friday, October 10, 2014 11:23 AM -
Corrupt WMI repository.
¯\_(ツ)_/¯
Friday, October 10, 2014 11:35 AM -
Friday, October 10, 2014 1:05 PM