?
Solved

VB Shell Command Opens Multiple Application Windows

Posted on 2003-02-19
5
Medium Priority
?
155 Views
Last Modified: 2013-12-25
Hello,

I've created a small application in VB5 to automatically ftp some data that I require weekly.

I use the Shell(pathname, [WindowNormalFocus]) command to open msdos prompt then SendKeys to type in the relevant data in the same way that this guy did:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20386977.html
(I think he's doing essentially the same thing as me).

The problem is sometimes it opens up 20 or so additional windows of msdos prompt for no obvious reason.  I don't have any wacky commands in there.  Can anyone think why or better yet how I can avoid it?  I was looking at the message boards and thought this might provide the answer:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_10054850.html

Can someone confirm this?
Thanks (PS I'm new and not much of a programmer)
0
Comment
Question by:griffithsk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
twalgrave earned 320 total points
ID: 7985163
If it's opening several DOS windows it is probably because you are calling shell several times.  Instead, use shell, get the return value, and use appactivate to activate the same window.  For instance:

dim lDosWindow as long
lDowWindow = shell("whatever")

appactivate lDosWindow
Sendkeys "This is a test"

appactivate lDosWindow
SendKeys "This is another test"

etc,etc,etc
0
 

Author Comment

by:griffithsk
ID: 7986030
Sorry, that's not it, I'm not even using AppActivate, because I only have to send one set of keystrokes, so the code goes (something like as I don't have it with me):

variable = Shell ("c:\windows\sytem32\cmd.exe", vbnormalfocus)
Variable
sendkeys ""blah blah blah"

Then the subroutine ends (except for the error routines).  It's a really basic process (which makes it all the more frustrating when it doesn't work).

Even better, yesterday for some reason it was looping the Sendkeys statement within the DOS window, and I don't have any loop or dowhile/until statements in there.
0
 

Author Comment

by:griffithsk
ID: 7988003
But don't worry about that, that's only happened once and it's not too much of an issue.
0
 

Author Comment

by:griffithsk
ID: 8680447
You may as well have the points, it's not the answer and the problrm hasn't been resolved but I want to close this and delete isn't an option.  Thanks for trying though!!
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 8684885
Thank you!  I wish I could have been more help.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question