Avatar of Saqib Husain
Saqib Husain
Flag for Pakistan asked on

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?
Microsoft ExcelVBA

Avatar of undefined
Last Comment
Saqib Husain

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Farzad Akbarnejad

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Rgonzo1971

HI,

pls try

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

Open in new window

Regards
Qlemo

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.
Saqib Husain

ASKER
Sorry, never got the chance to even test it, let alone apply it. So probably it is time to close the question now. Thanks
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck