?
Solved

HIding but still using a shell command

Posted on 2006-05-10
10
Medium Priority
?
155 Views
Last Modified: 2012-05-05
I have an application in which I use several cmd-line instructions to make things happen...

I am using
            ProcedureID = Shell("cmd.exe", AppWinStyle.NormalFocus)

to initiate my command shell session and I am typing commands through keybd_event in user32.dll using MapVirtualKey library.  I have about 20-35 commands to send to the shell and I find that the only way I can get it to work effectively is when I use AppWinStyle.NormalFocus and I would prefer to use AppWinStyle.Hide  This makes the commands fail with a Procedure not found error.

any ideas how I can get this all done without the users seeing the commands?  oh, and I have to give periodic feedback on which command is being run so the users do not think that the code has just frozen.


Thanks

0
Comment
Question by:lgropper
  • 4
  • 3
  • 3
10 Comments
 
LVL 9

Expert Comment

by:sk33v3
ID: 16652054
Hmm. Have you tried the following

Shell("Cmd.exe MyCommand1")
Shell("Cmd.exe MyCommand2")
Shell("Cmd.exe MyCommand3")
0
 

Author Comment

by:lgropper
ID: 16652065
that will not work, because I have other things to send the specific applications running in the shell command
0
 
LVL 9

Expert Comment

by:sk33v3
ID: 16652107
How much stuff do you have to send the other program? Will something like this work?

Shell("C:\MyCommand1.exe My Parameters")
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lgropper
ID: 16652165
No, it won't, because I have to wait for several things to happen then I have to send another command... then wait, then send more commands...  it is very tedious, but I have to write into this legacy system.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16652210
For keybd_event() to work, your target window needs to be visible, and in focus...it can't be minimized or hidden.

If you want the window hidden then you need a completely different approach to "automating" the cmd window!

I don't know off the top of my head how this would be done...
0
 

Author Comment

by:lgropper
ID: 16652310
I was thinking of using

Dim p As New System.Diagnostics.Process
        p.StartInfo.FileName = "cmd.exe"
or
        p.StartInfo.FileName = "ftp.exe"



What I really want to do is FTP some files using command line FTP...  I have tried wininet and a few others, and nothing else gives me what I want except the command line...  the only problem is sending commands to it and not having it visible to the users...


anyone here figure out a way to ftp using processes?  I just need a stable way to FTP using the command line...

0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 16652983
If your using command-line ftp then make a script for it.  You can tell ftp to execute your script using the "-s" option as in this PAQ:
http://www.experts-exchange.com/Programming/Q_21516930.html

So you make the script file if needed and use the StartInfo.Arguments parameter to pass it in...
0
 
LVL 9

Expert Comment

by:sk33v3
ID: 16654621
Ok, I would suggest that you build the FTP protocol into your application Using Sockets. This will give you more power, imho, than the dos FTP client will ever. Now I have noticed that you have Asked several Network programming related questions. I would suggest a second book that may interest you. http://www.amazon.com/gp/product/1555583156/sr=1-1/qid=1147311918/ref=sr_1_1/103-5679668-1269435?%5Fencoding=UTF8

Now if you are looking for speed of coding yes, idle_mind's suggestion is the best.

Here is a link to an FTP Client someone else coded
http://www.freevbcode.com/ShowCode.Asp?ID=4655

and another one

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=341&lngWId=10
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16654759
If you can handle the coding of the FTP yourself using sockets then that is the best option.  Using the ftp executable with a script is not very robust since you can't tell if the ftp was successfull or not...

0
 

Author Comment

by:lgropper
ID: 16667653
It was perfect!  Awesome... took a little fiddling with, but I was able to customize the concept to exactly what I wanted!

Thank you so much, this one really saved my bacon!

sk33v3, really liked yours execept both of them said that they were unable to successfully send via FTP which was my whole purpose here...  very kewl code though.  thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

839 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