Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试打开一个CMD窗口并在其中调用 dir 。
CMD
r = Shell("cmd.exe", vbNormalFocus) AppActivate r SendKeys "dir", True 'put your exe path/name here instead of dir SendKeys "{ENTER}"
它会打开cmd.exe,但根本不会打印dir或执行dir。
cmd.exe
dir
你为什么不简单地打电话:
r = Shell("cmd.exe /k dir", vbNormalFocus)
此调用将为您执行 cmd 中的 dir 命令,而无需使用 SendKeys。