标题: [文件操作] bat获取指定进程路径地址问题,请大神赐教 [打印本页]
作者: hulala 时间: 2020-2-26 15:51 标题: bat获取指定进程路径地址问题,请大神赐教
例如:wmic process where name="qq.exe" get executablepath
结果:
C:\Users\Administrator>wmic process where name="qq.exe" get executablepath
ExecutablePath
C:\Program Files (x86)\Tencent\QQ\Bin\QQ.exe
先结束QQ.exe
然后copy qq1.exe覆盖C:\Program Files (x86)\Tencent\QQ\Bin\QQ.exe
如果不用wmic还有其他什么办法?
具体命令怎么写,感谢大神
作者: flashercs 时间: 2020-2-26 16:07
为何不用wmic?这是最简单的方法.
当然你还可以自己写个console程序来读取.
作者: hulala 时间: 2020-2-26 16:19
回复 2# flashercs
用wmic也行,那能给出个具体代码吗?
作者: zaqmlp 时间: 2020-2-26 16:36
- @echo off
- set info=互助互利,支付宝扫码头像,感谢打赏
- rem 有问题,可加QQ956535081及时沟通
- title %info%
- cd /d "%~dp0"
- set "exename=qq.exe"
- set "exepath="
- for /f "tokens=1* delims==" %%a in ('wmic process where "name='%exename%'" get executablepath /value^|find "="') do (
- set "exepath=%%b"
- )
- if defined exepath (
- taskkill /f /im "%exename%"
- echo;"%exepath%"
- copy /y "qq1.exe" "%exepath%"
- )
- :end
- echo;%info%
- pause
- exit
复制代码
作者: flashercs 时间: 2020-2-26 16:50
回复 3# hulala - @echo off
- set "exename=qq.exe"
- set "exepath="
- for /f "tokens=1* delims==" %%a in ('wmic process where "name='%exename%'" get executablepath /value^|find "="') do (
- set exepath=%%b
- )
- if defined exepath (
- taskkill /f /im "%exename%"
- echo."%exepath%"
- copy /y "qq1.exe" "%exepath%"
- )
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |