0x90
0x90

Reputation: 40982

Why the code below doesn't trigger the dir call in a CMD window?

I am trying to open a CMD window and call dir in it.

r = Shell("cmd.exe", vbNormalFocus)
AppActivate r
SendKeys "dir", True 'put your exe path/name here instead of dir
SendKeys "{ENTER}"

It opens cmd.exe but doesn't print dir in it or execute dir at all.

Upvotes: 0

Views: 104

Answers (1)

rekire
rekire

Reputation: 47945

Why don't you simple call:

r = Shell("cmd.exe /k dir", vbNormalFocus)

This call will execute the dir command in cmd for you without playing with SendKeys.

Upvotes: 2

Related Questions