Sending "Command prompt" commands through VBA

How can I send the "Dir" command through VBA so that I can see the result in the Command prompt window of windows Xp, 7 and 8?
LVL 43
Saqib Husain, SyedEngineerAsked:
Who is Participating?
 
Farzad AkbarnejadDeveloperCommented:
Hi,
Try the following command in VBA code:

Shell "cmd /k dir"

-FA
0
 
Rgonzo1971Commented:
HI,

pls try

Call Shell("cmd.exe /S /K" & " dir", vbNormalFocus)

Open in new window

Regards
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
As those commands leave the window open, and you have to type exit oder close the window manually, I would rather use
  Shell "cmd /s /c dir && pause"
With this you only need to press a button to close the window, which is more convenient.
0
 
Saqib Husain, SyedEngineerAuthor Commented:
Sorry, never got the chance to even test it, let alone apply it. So probably it is time to close the question now. Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.