|
-
Jun 19th, 2013, 04:49 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Opening a game with a button
i'm making my final version of my software and i have a big problem i want to open a game with a button, sounds simple but i can't, i tryed shell, process.start, peocess.start("cmd", "/c or /k") and even system.diagnostics and all of them have the same problem they open it but the game crashes on startup or if is a luncher any of the file requested aren't opened in others words is like opening the .exe file of the game with no external files, but i don't have this problem with any program only with games
Last edited by evo74; Jun 19th, 2013 at 04:52 AM.
Reason: write mistake
-
Jun 19th, 2013, 05:22 AM
#2
Re: Opening a game with a button
The most common reason for this issue is the working directory. When you run an EXE from the commandline, its working directory will be the folder containing the EXE. If you run an EXE by calling Process.Start, its working directory will be the working directory of your current process by default, which will probably be the folder containing the EXE of the current program but may have been changed. What you need to do is set the working directory of the new process explicitly. To that end, create a ProcessStartInfo object, configure it appropriately and then pass it as an argument to Process.Start. Note that, if you have the path of the EXE to run, you can use the IO.Path.GetDirectoryName method to get the path of the folder containing it.
-
Jun 19th, 2013, 06:35 AM
#3
Thread Starter
Addicted Member
Re: Opening a game with a button
thx jmcilhinney that worked like a charm
Code:
Dim Game1 As New ProcessStartInfo
Game1.FileName = My.Settings.GamePath1
Game1.UseShellExecute = True
Game1.WindowStyle = ProcessWindowStyle.Normal
Game1.WorkingDirectory = IO.Path.GetDirectoryName(My.Settings.GamePath1)
Dim Game1proc As Process = Process.Start(Game1)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|