如何让 powershell 告诉我丢失的 DLL? [英] How to make powershell tell me about missing DLLs?

查看:60
本文介绍了如何让 powershell 告诉我丢失的 DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 中使用 powershell 作为 shell.当我尝试启动一些在 PATH 环境变量中缺少 dll 依赖项的应用程序时,没有任何反应,powershell 只是默默地返回新的命令提示符.

I use powershell as shell in Windows. When I'm trying to launch some application who's dll dependencies are missing in PATH environment variable, then nothing happens, powershell just silently returns with new command prompt.

有没有办法让 powershell 失败的声音更大,告诉我到底缺少什么,就像默认的 cmd shell 那样?

Is there a way to make powershell fail louder, telling me what exactly is missing, like default cmd shell does?

推荐答案

我遇到了同样的问题.PowerShell 正在将 $LASTEXITCODE 代码设置为 -1073741515 (0xC0000142, 3221225794) 但没有输出解释实际错误.通过 cmd.exe 运行它时,我会弹出如下内容:

I was having this same problem. PowerShell was setting $LASTEXITCODE code to -1073741515 (0xC0000142, 3221225794) but no output explaining what was actually wrong. When running it via cmd.exe I would get popup with something like:

无法继续执行代码,因为找不到 some.dll.重新安装程序可能会解决此问题.

The code execution cannot proceed because some.dll was not found. Reinstalling the program may fix this problem.

cygwin bash 将与未找到的 dll 相关的错误输出到 stderr,如果您从 PowerShell 通过 bash 运行相同的错误,那么您可以看到错误:

cygwin bash outputs errors relating to dll not found to stderr and if you run the the same via bash from PowerShell then you can see the error:

> & 'C:\tools\cygwin\bin\bash.exe' '-c' '"C:/Users/xxx/dir/main.exe"'
C:/Users/xxx/dir/main.exe: error while loading shared libraries: another.dll: cannot open shared object file: No such file or directory

这也适用于 git bash:

This works with git bash also:

> & 'C:\Program Files\Git\bin\bash.exe' '-c' '"C:/Users/xxx/dir/main.exe"'
C:/Users/xxx/dir/main.exe: error while loading shared libraries: another.dll: cannot open shared object file: No such file or directory

相当有技巧,但总比没有好.

Quite a hack but better than nothing.

这篇关于如何让 powershell 告诉我丢失的 DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆