Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, I am wondering if it is possible to start a executable with options in vb.net. Basically I can run a game via start>run, and then add the option +restart 1.

 

So I am running: E:\program files\games\game.exe +restart 1

 

Everything works fine but I cannot seem to find a way to do it in an application. I have tried to Shell it, use the System.Diagnostics.Process.Start method, and also just create a new Process and start it. Most ways give a file not found exception, some do not. Basically when it works the introduction is skipped. I think the main problem is that I have no idea what this is called, Arguments? EnvironmentVariables? Any ideas or thoughts would be greatly appreciated!

  • *Experts*
Posted
System.Diagnostics.Process.Start("E:\Program Files\Games\Game.exe", "+restart 1")

:) the Process.Start function has a separate parameter for command line parameters (arguments).

Posted

Thanks for the reply! I actually tried that and it is not working either. In fact just System.Diagnostics.Process.Start("E:\Program Files\Games\Game.exe") does not open it. The computer sounds like it is doing something for a split second but in the end, does nothing.

 

I checked the task manager and it does pop up the game then the game closes which is the same thing that happens when an incorrect arg is sent in. This game seems to dislike this and all shell methods.

 

Is there a way to use the run feature of windows?

  • 4 weeks later...
  • 3 weeks later...
Posted

Sorry for the late reply!

 

Dim pr As New ProcessStartInfo()

pr.WorkingDirectory = "WORKING DIRECTORY" 'Working directory here

pr.FileName = "FILE PATH"

pr.Arguments = "ARGUMENTS"

pr.UseShellExecute = True

Process.Start(pr)

  • *Experts*
Posted
Working directory is the "default directory" in the program's eyes; if the program attempts to access file using relative path (i.e. "images\img.jpg" instead of "c:\game\moo\images\img.jpg"), that is the directory it will look in.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...