[VB]Button to Launch Client

Joined
Mar 17, 2009
Messages
1,917
Reaction score
539
Hey, im trying to make a client for my private server. I made a button called 'Play'

Source:

Code:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            MsgBox(OpenFileDialog1.FileName)
        End If
    End Sub

I was wondering if someone could help me make it that, when you click play. You just double click on the client and it loads (Not right click run)

If you double click it, it presses 'Select'

I was also wondering if i could make it save for the next time round.

Im using Visual Basic 2008.

All help is greatly appreciated.
 
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If (My.Computer.FileSystem.FileExists("main.exe")) Then
            Process.Start("main.exe")
        Else
            MsgBox("Can't find object 'main.exe', please put launcher in your client.", MsgBoxStyle.Critical, "Error!")
        End If
    End Sub
take :):
 
When calling Process.Start() don't you need to have the full file path?

PHP:
if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
	Process.Start(openFileDialog1.FileName);

The if is in there to check if the user clicked cancel otherwise Process.Start() will screw up.
 
Last edited:
Well the code for this in delphi is
Code:
Procedure StartProgram(ProgramName:string);
begin
Winexec(Pansichar(ProgramName),SW_NORMAL);
end;

// Then in a button or whatever ...

procedure Tform1.button1click(sender:tobject);
begin
Start('notepad.exe'); // start whatever program you want
end;
 
Back