[英]How do I get the parent command in Windows command line?
在Unix shell中,我可以使用ps -ocommand= -p $PPID
獲得父命令。 如何在Windows Shell中執行相同操作?
我需要一個Git預提交鈎子來檢測提交是否使用--amend
標志啟動。
粗略的方法是使用標題查詢查找當前的PID。
title ABC
for /f "tokens=2" %%P in ('tasklist /V ^| findstr "ABC"') do set CurrentPid=%%P
for /f "tokens=2 skip=1" %%P in ('wmic process where ProcessId^=%CurrentPid% get Caption^,ParentProcessId^,ProcessId') do set ParentProcessId=%%P
wmic process where ProcessId=%ParentProcessId% get CommandLine
那里有很多可以優化的地方。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.