Welcome to Dream.In.Code
Become a VB Expert!

Join 149,483 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,390 people online right now. Registration is fast and FREE... Join Now!




Display command line within a form

 
Reply to this topicStart new topic

Display command line within a form, is this possible?

theholygod
25 Apr, 2007 - 07:13 AM
Post #1

D.I.C Head
**

Joined: 5 Feb, 2006
Posts: 223


My Contributions
I've recently started playing with shell commands in VB, more specifically giving the user buttons which will generate some code in the background which is then fed to the command line.

My knowledge of VB is pretty small, and what i have written so far is hardly impressive.

So anyway, on my form i would like to display the command line or at least have values returned, rather than having the command line popup in the backgroud to do its thing.

Is there a way to do this? if there is please explain it fairly simply, im no expert with vb.
User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Display Command Line Within A Form
25 Apr, 2007 - 08:18 AM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,101



Thanked: 25 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
i'm not sure you can avoid the cmd line entirely, but you can suppress it, i have an exam quite soon, so if no1 else is able to answer i'll find it in my coding after.
You can force the size of the prompt, force minimized, but i'm not sure if you can make it invisible all together.

Is this VB6 or VB 2005?
User is offlineProfile CardPM
+Quote Post

snoj
RE: Display Command Line Within A Form
25 Apr, 2007 - 08:26 AM
Post #3

Fell off the face of the earth
Group Icon

Joined: 31 Mar, 2003
Posts: 3,325



Thanked: 9 times
Dream Kudos: 750
My Contributions
Assuming you're using the wshell.script object, I think you're looking for this?
User is offlineProfile CardPM
+Quote Post

theholygod
RE: Display Command Line Within A Form
25 Apr, 2007 - 09:35 AM
Post #4

D.I.C Head
**

Joined: 5 Feb, 2006
Posts: 223


My Contributions
Im using VB Express 2005. I know you can force the command line to be hidden, but this isnt what i want.

Not quite what im looking for hotsnoj, but i can definately see it being useful.

Im using
Shell("cmd /k " & Command)
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Display Command Line Within A Form
25 Apr, 2007 - 10:06 AM
Post #5

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,302



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Yes, you can do as you are asking. You need to create a new process object.

Check out the following link for information on this subject.
http://www.devx.com/dotnet/Article/7914

Here is also a little snippet I found which should give you some insight as to how to use the command window as the process. In the following example its using the ping command in the command window. The command window will still open, but will only exist as long as the command is running. In this case the results returned from the ping will display in a MessageBox after the window closes.

CODE

        Dim p As New Process
        Dim pi As New ProcessStartInfo
        pi.UseShellExecute = False
        pi.RedirectStandardOutput = True
        pi.Arguments = "www.google.com"
        pi.WorkingDirectory = "C:\\windows\\system32"
        pi.FileName = "ping"
        p.StartInfo = pi
        p.Start()
        Dim sr As IO.StreamReader = p.StandardOutput
        Dim sb As New System.Text.StringBuilder("")
        Dim input As Integer = sr.Read
        Do Until input = -1
            sb.Append(ChrW(input))
            input = sr.Read
        Loop
        MessageBox.Show(sb.ToString)

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 04:36PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month