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

Member Avatar for iamthwee

hmm i don't know for sure, but look into the process command, maybe you could just pass strings to it.

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.

commented: good +11

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

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()

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

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

thank you waynespangler with your help i was able to solve a issue

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.

thank you waynespangler with your help i was able to solve a issue

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.