Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using SendKeys, cmd.exe, Vista

Status
Not open for further replies.

BobRodes

Instructor
May 28, 2003
4,215
US
I can't find anything on this one. I have the following code:
Code:
Shell "C:\windows\system32\cmd.exe", vbMaximizedFocus
SendKeys "cd \"
SendKeys "{enter}"
I'm using Vista 32 bit. Running this code opens a seemingly random number of instances of the command window, the lowest 45 and the highest 60.

Is this a known problem with using SendKeys in Vista? If so, do we have to get into using SendMessage to use DOS command prompt in Vista, or is there an easier workaround?

An unintended consequence of the information revolution has been the exponential propagation of human error.
 
Weird.

On my computer (running in the IDE), I get 4 instances started. I'm running on Vista 64 bit.

Perhaps you could try creating a batch file on file system and then run the cmd command with the batch file.

I also tried this (which seems to do what you want):

Code:
Shell "C:\windows\system32\cmd.exe /k cd \", vbMaximizedFocus

i.e. It starts a command window in the root of the c drive.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Thanks George, that does work. The person needing the answer actually needed the window to go away after running, so I'll point out for anyone reading that /c is the switch to use for that instead of /k. I'll pass the info along.

An unforeseen consequence of the information revolution has been the exponential propagation of human error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top