Visual Basic - Button to run command or vb script?

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.
 
L

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.

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
 
T

Tom Shelton

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.
 
M

mrmwalter

Lloyd - Tom,

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top