Visual Basic - Button to run command or vb script?

  • Thread starter Thread starter mrmwalter
  • Start date Start date
M

mrmwalter

Hi,

I need to create a GUI that has a form, on the form it asks for
username. I therefore decided to use Visual Basic (not much
experience_ On the form will be a button, how do I get this button to
then launch a vbscript, oe even a batch file when it is clicked?

Thanks.
 
Hi,

I need to create a GUI that has a form, on the form it asks for
username. I therefore decided to use Visual Basic (not much
experience_ On the form will be a button, how do I get this button to
then launch a vbscript, oe even a batch file when it is clicked?

Thanks.

What you are looking for is the Process class.

There are several versions of Process.Start. If the filename extension is
known to windows you can use the simple one by just using the name of the
file you want to start (acts like a double click in explorer).

If you have parameters there is a version where you give the filename
followed by a string with the parameters.

It would be something like (not a workstation with VS).

dim p as Process
p=Process.Start("C:\my folder\my batchfile.bat")
p.WaitForExit()

the last statement will wait until the process finishes if this is important
to what you are doing.

Hope this helps
LLoyd Sheen
 
Hi,

I need to create a GUI that has a form, on the form it asks for
username. I therefore decided to use Visual Basic (not much
experience_ On the form will be a button, how do I get this button to
then launch a vbscript, oe even a batch file when it is clicked?

Thanks.

Take a look at System.Diagnostics.Process. If you have any further
questions, let us know.
 
Lloyd - Tom,

That's excellent - does exactly what I wanted it to do - thanks very
much for your help, very much appreciated!
 
Back
Top