Mac_dm

Hi all,
I am just learning a little VB and trying to write some apps for work.
all I really want to do is put a GUI interface on command line programs like netdom, dsadd and such. I am having trouble getting the variables I create with input from the app to dynamicly fill the command line arguments. Is there an easy way to do this that I can replace the arguments of a program like netdom with the input of the boxes in the form I create So when the user presses the button the script will exicute the netdom program with the supplied variables.. I hope I am making sense to someone
Here is the netdom Arguments I have been working with.
netdom.exe renamecomputer 192.168.1.1 /newname:computer1 /userD:domain.local\administrator /passwordd:password /reboot:60
everything in bold I have a box and request input from the user I just dont know how to execute the whole command with a button event...
Thanks



Re: Visual Basic Express Edition Beginner VB question

DMan1

Use the process and ProcessStartInfo Classes:

(the following is pseudo code (don't have my VB environment up right now)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim P as New Process()

Dim SI as New ProcessStartInfo

SI.FileName="netdom.exe"

SI.Arguements="renamecomputer " & TextBox1.text....'you can also use a stringbuilder here to build the arg string

P.StartInfo=SI

P.Start

End Sub 'Button1






Re: Visual Basic Express Edition Beginner VB question

Mac_dm

Thanks for the reply. I think I see what you are doing I am still having one problem.

Dim P As New Process()

Dim SI As New ProcessStartInfo

SI.FileName = "netdom.exe"

SI.Arguments = "renamecomputer " & txtold.Text & "" & "/newname:" txtnew.Text

P.StartInfo = SI

P.Start()

at txtnew.text I get error saying "End of statement expected" What is it expecting

I thought I could just make something like.

SI.Arguments = "renamecomputer " & txtold.text & "" & "/newname:" txtnew.Text "/userD:domain\" admin.text & "" & "/passwordd:" password.text & "" & "/reboot:" seconds.text

To repesent this: renamecomputer 192.168.1.1 /newname:computer1 /userD:domain.local\administrator /passwordd:password /reboot:60

I am pretty new at this so dont be too hard on me . Thanks for the help...

-Dave






Re: Visual Basic Express Edition Beginner VB question

DMan1

You forgot you concantenation character "&"

SI.Arguments = "renamecomputer " & txtold.Text & "" & "/newname:" txtnew.Text

Should be:

SI.Arguments = "renamecomputer " & txtold.Text & "" & "/newname:" & txtnew.Text






Re: Visual Basic Express Edition Beginner VB question

Chris Dunaway

You have omitted the string concatenation operator (&) in several places:


SI.Arguments = "renamecomputer " & txtold.text & "" & "/newname:" & txtnew.Text
& "/userD:domain\" & admin.text & "" & "/passwordd:" & password.text & "" & "/reboot:" & seconds.text


Chris





Re: Visual Basic Express Edition Beginner VB question

Mac_dm

Ha Ha, nice.. well that worked you all rock!! thanks