GNU 当前离线
上尉
另外,我发现wmic的路径结果很难被 if 使用,显示没问题,真难用。
TOP
WHY 当前离线
上校
dir 'HKLM:\SOFTWARE\Microsoft\Office\*\Common\InstallRoot' | %{ ($_.Name -Split '\\')[-3];(gp $_.PSPath).'Path' }复制代码
@echo off set "key=HKLM\SOFTWARE\Microsoft\Office" for /f "delims=" %%i in ('reg query "%key%" ^| findstr "^HKEY_.*\\[0-9][0-9.]*$"') do ( echo;%%~nxi for /f "tokens=1,2*" %%i in ('reg query "%%i\Common\InstallRoot"') do if "%%i" == "Path" echo;%%k ) pause复制代码
评分人数
aries215 当前离线
三级士官
@echo off SetLocal EnableDelayedExpansion for /f "skip=1 delims==" %%a in ('wmic process where name^="notepad.exe" get executablepath') do ( set "_var=%%~a" echo,!_var! start "!_var!" ) pause复制代码
@echo off SetLocal EnableDelayedExpansion for /f "tokens=2 delims==" %%a in ('wmic process where name^="hash.exe" get executablepath /value ^| findstr "="') do ( set "_var=%%~a" start "" "!_var:~0,-1!" goto :end ) :end pause复制代码