943,597 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 18310
  • VB.NET RSS
Jul 20th, 2007
0

how to call command window with VB.NET programme

Expand Post »
hi,

i want to integrate VB.NET with command window.
in fact, i want the interface(built on VB.NET) to open the command window and it should automatically change the path to C:\Perl\eg and then it has to execute automatically the file what i specified. for this i already used the code given below .

Shell("cmd.exe /k cd C:\Perl\eg", vbNormalFocus)

when i add this code, its opening the command window and the path is changed to C:\Perl\eg. but i need to type the below command on command prompt after changing the path to execute the perl code.

ex: perl filename.pl

But i want the above command to be executed automatically not manually. For that i've to add that command somewhere in VB.NET. But i don't know where to add and how to add exactly.
i hope somebody helps with this as early as possible.


thank u.
chandrag
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chandrag is offline Offline
19 posts
since Jul 2007
Jul 20th, 2007
0

Re: how to call command window with VB.NET programme

hmm i don't know for sure, but look into the process command, maybe you could just pass strings to it.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Jul 21st, 2007
1

Re: how to call command window with VB.NET programme

Try this in your main form load event:
VB.NET Syntax (Toggle Plain Text)
  1. Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2. Dim process As New Process
  3. With process
  4. With .StartInfo
  5. .FileName = "perl.exe"
  6. .Arguments = "filename.pl"
  7. .WorkingDirectory = "C:\Perl\eg"
  8. End With
  9. .Start()
  10. End With
  11. End Sub

Without the With statement:
VB.NET Syntax (Toggle Plain Text)
  1. Dim process As New Process
  2. process.StartInfo.FileName = "perl.exe"
  3. process.StartInfo.Arguments = "filename.pl"
  4. process.StartInfo.WorkingDirectory = "C:\Perl\eg"
  5. process.Start()

Read up on the Process function. Can do a lot more than Shell. Like redirect the output to a textbox so you don't have to remember what the dos screen said.
Last edited by waynespangler; Jul 21st, 2007 at 10:10 am.
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Jul 23rd, 2007
0

Re: how to call command window with VB.NET programme

Try this in your main form load event:
VB.NET Syntax (Toggle Plain Text)
  1. Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2. Dim process As New Process
  3. With process
  4. With .StartInfo
  5. .FileName = "perl.exe"
  6. .Arguments = "filename.pl"
  7. .WorkingDirectory = "C:\Perl\eg"
  8. End With
  9. .Start()
  10. End With
  11. End Sub

Without the With statement:
VB.NET Syntax (Toggle Plain Text)
  1. Dim process As New Process
  2. process.StartInfo.FileName = "perl.exe"
  3. process.StartInfo.Arguments = "filename.pl"
  4. process.StartInfo.WorkingDirectory = "C:\Perl\eg"
  5. process.Start()

Read up on the Process function. Can do a lot more than Shell. Like redirect the output to a textbox so you don't have to remember what the dos screen said.
hi Wayne,

tremendous. thank u very much for ur help.
it is working. excellent.
thank u very very much once again.
and one more thing is that i want that result to be shown in my interface. what to do for that?

thank u
chandrag
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chandrag is offline Offline
19 posts
since Jul 2007
Jul 23rd, 2007
1

Re: how to call command window with VB.NET programme

Try this:
VB.NET Syntax (Toggle Plain Text)
  1. Dim process As New Process
  2. process.StartInfo.FileName = "perl.exe"
  3. process.StartInfo.Arguments = "filename.pl"
  4. process.StartInfo.WorkingDirectory = "C:\Perl\eg"
  5. process.StartInfo.UseShellExecute = False
  6. process.StartInfo.ErrorDialog = False
  7. process.StartInfo.RedirectStandardOutput = True
  8. process.Start()
  9. TextBox1.Text = process.StandardOutput.ReadToEnd
  10. process.WaitForExit()
Last edited by waynespangler; Jul 23rd, 2007 at 10:56 am.
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Jul 23rd, 2007
0

Re: how to call command window with VB.NET programme

Try this:
VB.NET Syntax (Toggle Plain Text)
  1. Dim process As New Process
  2. process.StartInfo.FileName = "perl.exe"
  3. process.StartInfo.Arguments = "filename.pl"
  4. process.StartInfo.WorkingDirectory = "C:\Perl\eg"
  5. process.StartInfo.UseShellExecute = False
  6. process.StartInfo.ErrorDialog = False
  7. process.StartInfo.RedirectStandardOutput = True
  8. process.Start()
  9. TextBox1.Text = process.StandardOutput.ReadToEnd
  10. process.WaitForExit()
hi,

i tried it. but there is no result.
it's opening the command window. but it's not executing anything.
it's not closing as well. and it's not giving any result in text box.

chandrag
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chandrag is offline Offline
19 posts
since Jul 2007
Jul 23rd, 2007
0

Re: how to call command window with VB.NET programme

Click to Expand / Collapse  Quote originally posted by chandrag ...
hi,

i tried it. but there is no result.
it's opening the command window. but it's not executing anything.
it's not closing as well. and it's not giving any result in text box.

chandrag
hi

i've got it. it's working.
thak u very much. earlier i was closing when it was in process.
but now i waited for some time and got the result. thank u so much for ur kind help.

thank u once again.
chandrag
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chandrag is offline Offline
19 posts
since Jul 2007
Feb 9th, 2011
0
Re: how to call command window with VB.NET programme
thank you waynespangler with your help i was able to solve a issue
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pohvak is offline Offline
2 posts
since Apr 2008
Feb 9th, 2011
0
Re: how to call command window with VB.NET programme
Try this in your main form load event:
VB.NET Syntax (Toggle Plain Text)
  1. Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2. Dim process As New Process
  3. With process
  4. With .StartInfo
  5. .FileName = "perl.exe"
  6. .Arguments = "filename.pl"
  7. .WorkingDirectory = "C:\Perl\eg"
  8. End With
  9. .Start()
  10. End With
  11. End Sub

Without the With statement:
VB.NET Syntax (Toggle Plain Text)
  1. Dim process As New Process
  2. process.StartInfo.FileName = "perl.exe"
  3. process.StartInfo.Arguments = "filename.pl"
  4. process.StartInfo.WorkingDirectory = "C:\Perl\eg"
  5. process.Start()

Read up on the Process function. Can do a lot more than Shell. Like redirect the output to a textbox so you don't have to remember what the dos screen said.


thank you waynespangler with your help i was able to solve a issue
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pohvak is offline Offline
2 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Class using timers
Next Thread in VB.NET Forum Timeline: Updating Database - VB.NET





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC