【发布时间】:2018-01-06 13:39:59
【问题描述】:
如果您在默认的 Windows 安装中运行命令 shell,请键入 mspaint 并按 Enter,Paint 将启动。
有没有办法(以编程方式)确定命令是否可执行?
【问题讨论】:
-
您可以运行
where mspaint,然后检查%ERRORLEVEL%变量,如果最后一个命令完成且没有错误(找到目标可执行文件)则为0,如果有错误(未找到)则为1。跨度>
如果您在默认的 Windows 安装中运行命令 shell,请键入 mspaint 并按 Enter,Paint 将启动。
有没有办法(以编程方式)确定命令是否可执行?
【问题讨论】:
where mspaint,然后检查%ERRORLEVEL% 变量,如果最后一个命令完成且没有错误(找到目标可执行文件)则为0,如果有错误(未找到)则为1。跨度>
要分析给定文件,您可以使用作为Visual Studio 的一部分分发的dumpbin.exe 工具。
示例输出:
C:\>dumpbin z3.exe
Microsoft (R) COFF/PE Dumper Version 14.00.24213.1
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file z3.exe
File Type: EXECUTABLE IMAGE
C:\>dumpbin what.com
Microsoft (R) COFF/PE Dumper Version 14.00.24213.1
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file what.com
what.com : warning LNK4048: Invalid format file; ignored
【讨论】: