process - 如何使用自动热键获取进程的目录?
问题描述
我想找出一个进程的目录。目前,我正在使用此脚本来检查进程是否正在运行:
If ProcessExist("MEmuHeadless.exe")
MsgBox MEmuHeadless.exe exists.
If !ProcessExist("MEmuHeadless.exe")
MsgBox Ofcourse it doesn't exist.
ProcessExist(Name){
Process,Exist,%Name%
return Errorlevel
}
但更重要的是,我想检查进程的目录是否与此匹配:
我怎样才能在自动热键中做到这一点?
解决方案
我为你找到了这个解决方案。看来您必须搜索一些 com 对象才能获取有关该过程的额外信息。
Msgbox % GetProcessPath( "Autohotkey.exe" )
ExitApp
GetProcessPath(exe) {
for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where name ='" exe "'")
return process.ExecutablePath
}
推荐阅读
- c - 用C中的常数计算浮点数?
- python - 如何对每行中具有分类值列表的特征进行编码以训练机器学习模型?
- android-studio - 如何在 Flutter 的 onPressed 方法中获取 radioButton 值
- python - “charmap”编解码器无法解码位置 5697 中的字节 0x9d:字符映射到
- c++ - 尝试打开目录进行读取时,CreateFile 总是返回错误 5(访问被拒绝)
- javascript - 收银机免费代码营算法需要帮助
- java - 尽管在同一个包和一个扫描组件中,但 Spring 未检测到组件
- java - java DateFormat - 获取印度的默认日期模式为 DD-MM-YY
- nginx - 如何从 Nginx 的基本身份验证中排除路由?
- typescript - Axios + Typescript:如何传递“ResponseType”类型的参数?