User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 392,085 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,922 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 4433 | Replies: 6
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,668
Reputation: iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice iamthwee is just really nice 
Rep Power: 17
Solved Threads: 298
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.
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Dec 2002
Location: West Virginia
Posts: 369
Reputation: waynespangler is on a distinguished road 
Rep Power: 6
Solved Threads: 34
waynespangler waynespangler is offline Offline
Posting Whiz

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 9: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: 369
Reputation: waynespangler is on a distinguished road 
Rep Power: 6
Solved Threads: 34
waynespangler waynespangler is offline Offline
Posting Whiz

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 9: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)

 

DaniWeb VB.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 12:31 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC