SendKeys not sending to Cmd.exe
Maybe you can use something like this:
dim myFileName as string
dim myParms as string
myfilename = "ipconfig"
myparms = "/all"
Shell Environ("comspec") _
& " /k " & Chr(34) & myFileName & Chr(34) & " " & myparms, vbNormalFocus
Use /c says to close that (hidden!) window when it's done.
The /k to see the command window (/k = keep open) (nice for testing).
I used /k and NormalFocus to test.
I'd use /c and vbHide when I was done testing.
But I would think you'd want to open the output of that ipconfig command.
Maybe something like:
Dim myFileName As String
Dim myParms As String
myFileName = "ipconfig"
myParms = "/all C:\myfile.txt"
Shell Environ("comspec") _
& " /c " & Chr(34) & myFileName & Chr(34) & " " & myParms, vbHide
Would work ok.
AltaEgo wrote:
Hi all
W7
XL2007
(same problem on XP. 2003)
Cannot use Cscript or Wscript.
I need to send some commands to a command window. Tested this code (and
variations). The Cmd window receives no keystrokes but the Msgbox pops up.
Sub test()
Dim ReturnValue
ReturnValue = Shell("CMD.EXE", 5)
'AppActivate ReturnValue
'will err when uncommented
SendKeys "ipconfig /all {ENTER}", True
MsgBox "done"
End Sub
--
Steve
--
Dave Peterson
|