how to call command window with VB.NET programme

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2007
Posts: 19
Reputation: chandrag is an unknown quantity at this point 
Solved Threads: 0
chandrag chandrag is offline Offline
Newbie Poster

how to call command window with VB.NET programme

 
0
  #1
Jul 20th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

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

 
0
  #2
Jul 20th, 2007
hmm i don't know for sure, but look into the process command, maybe you could just pass strings to it.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

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

 
1
  #3
Jul 21st, 2007
Try this in your main form load event:
  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:
  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.
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 19
Reputation: chandrag is an unknown quantity at this point 
Solved Threads: 0
chandrag chandrag is offline Offline
Newbie Poster

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

 
0
  #4
Jul 23rd, 2007
Originally Posted by waynespangler View Post
Try this in your main form load event:
  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:
  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
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

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

 
1
  #5
Jul 23rd, 2007
Try this:
  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.
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 19
Reputation: chandrag is an unknown quantity at this point 
Solved Threads: 0
chandrag chandrag is offline Offline
Newbie Poster

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

 
0
  #6
Jul 23rd, 2007
Originally Posted by waynespangler View Post
Try this:
  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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 19
Reputation: chandrag is an unknown quantity at this point 
Solved Threads: 0
chandrag chandrag is offline Offline
Newbie Poster

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

 
0
  #7
Jul 23rd, 2007
Originally Posted by chandrag View Post
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 10284 | Replies: 6
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC