RSS Forums RSS
Please support our VB.NET advertiser: Programming Forums
Views: 6101 | Replies: 6 | Thread Tools  Display Modes
Reply
Join Date: Jul 2007
Posts: 19
Reputation: chandrag is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
chandrag chandrag is offline Offline
Newbie Poster

Help how to call command window with VB.NET programme

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 4,844
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 325
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

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

  #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  
Join Date: Dec 2002
Location: West Virginia
Posts: 434
Reputation: waynespangler is on a distinguished road 
Rep Power: 7
Solved Threads: 50
waynespangler waynespangler is offline Offline
Posting Pro in Training

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

  #3  
Jul 21st, 2007
Try this in your main form load event:
	Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
	Dim process As New Process
	With process
		With .StartInfo
			.FileName = "perl.exe"
			.Arguments = "filename.pl"
			.WorkingDirectory = "C:\Perl\eg"
		End With
		.Start()
	End With
    End Sub

Without the With statement:
		Dim process As New Process
		process.StartInfo.FileName = "perl.exe"
		process.StartInfo.Arguments = "filename.pl"
		process.StartInfo.WorkingDirectory = "C:\Perl\eg"
		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  
Join Date: Jul 2007
Posts: 19
Reputation: chandrag is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
chandrag chandrag is offline Offline
Newbie Poster

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

  #4  
Jul 23rd, 2007
Originally Posted by waynespangler View Post
Try this in your main form load event:
	Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
	Dim process As New Process
	With process
		With .StartInfo
			.FileName = "perl.exe"
			.Arguments = "filename.pl"
			.WorkingDirectory = "C:\Perl\eg"
		End With
		.Start()
	End With
    End Sub

Without the With statement:
		Dim process As New Process
		process.StartInfo.FileName = "perl.exe"
		process.StartInfo.Arguments = "filename.pl"
		process.StartInfo.WorkingDirectory = "C:\Perl\eg"
		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  
Join Date: Dec 2002
Location: West Virginia
Posts: 434
Reputation: waynespangler is on a distinguished road 
Rep Power: 7
Solved Threads: 50
waynespangler waynespangler is offline Offline
Posting Pro in Training

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

  #5  
Jul 23rd, 2007
Try this:
		Dim process As New Process
		process.StartInfo.FileName = "perl.exe"
		process.StartInfo.Arguments = "filename.pl"
		process.StartInfo.WorkingDirectory = "C:\Perl\eg"
		process.StartInfo.UseShellExecute = False
		process.StartInfo.ErrorDialog = False
		process.StartInfo.RedirectStandardOutput = True
		process.Start()
		TextBox1.Text = process.StandardOutput.ReadToEnd
		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  
Join Date: Jul 2007
Posts: 19
Reputation: chandrag is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
chandrag chandrag is offline Offline
Newbie Poster

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

  #6  
Jul 23rd, 2007
Originally Posted by waynespangler View Post
Try this:
		Dim process As New Process
		process.StartInfo.FileName = "perl.exe"
		process.StartInfo.Arguments = "filename.pl"
		process.StartInfo.WorkingDirectory = "C:\Perl\eg"
		process.StartInfo.UseShellExecute = False
		process.StartInfo.ErrorDialog = False
		process.StartInfo.RedirectStandardOutput = True
		process.Start()
		TextBox1.Text = process.StandardOutput.ReadToEnd
		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  
Join Date: Jul 2007
Posts: 19
Reputation: chandrag is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
chandrag chandrag is offline Offline
Newbie Poster

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

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 4:54 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC