C
C#2y ago
The Joker

❔ Process.Start() Retroarch Emulator C#

Hello, I need some help with a code, I'm trying to run the retroarch emulator with the Process.Start command, the emulator even opens but it opens without the game, I believe I must be making a mistake in the command line I'm using a listbox to get the name of the game.
private void startGame()
{
string rom = @"ROMFILES\Sega Genesis\" + lsbRoms.Text + ".zip";
string emulator = @"EMULATOR\Sega Genesis\retroarch.exe";
string commandline = string.Format("-L {0} {1}", @"EMULATOR\Sega Genesis\cores\genesis_plus_gx_libretro.dll");

if (!File.Exists(emulator))
{
MessageBox.Show("Emulator is required to continue.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

else
{
Process.Start(emulator, "\"" + commandline + rom);
}
}
private void startGame()
{
string rom = @"ROMFILES\Sega Genesis\" + lsbRoms.Text + ".zip";
string emulator = @"EMULATOR\Sega Genesis\retroarch.exe";
string commandline = string.Format("-L {0} {1}", @"EMULATOR\Sega Genesis\cores\genesis_plus_gx_libretro.dll");

if (!File.Exists(emulator))
{
MessageBox.Show("Emulator is required to continue.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

else
{
Process.Start(emulator, "\"" + commandline + rom);
}
}
15 Replies
Monsieur Wholesome
Youre missing a second argument btw
saltypatron.eth
A long time ago, i flushed out running cmd processes from C# to run a utility to help me parse ESRI shapefiles... ive done many more dumb things since then but this is what i came up with:
The Joker
The JokerOP2y ago
Several attempts but still no success.
private void startGame()
{
string rom = @"ROMS\Sega Genesis\" + lsbRoms.Text + ".zip";
string emulator = @"EMULATOR\Sega Genesis\retroarch.exe";
string commandline = string.Format("-L {0} {1}", @"EMULATOR\Sega Genesis\cores\genesis_plus_gx_libretro.dll", rom);

if (!File.Exists(emulator))
{
MessageBox.Show("Emulator is required to continue.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

else
{
Process.Start(emulator, "\"" + commandline);
}
}
private void startGame()
{
string rom = @"ROMS\Sega Genesis\" + lsbRoms.Text + ".zip";
string emulator = @"EMULATOR\Sega Genesis\retroarch.exe";
string commandline = string.Format("-L {0} {1}", @"EMULATOR\Sega Genesis\cores\genesis_plus_gx_libretro.dll", rom);

if (!File.Exists(emulator))
{
MessageBox.Show("Emulator is required to continue.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

else
{
Process.Start(emulator, "\"" + commandline);
}
}
saltypatron.eth
what is the value of lsbRoms.Text? do you get a good name populated in rom? have you printed out the command line and tried to run it in a terminal instead of through here? Im not sure Process.Start attaches it's output to the console that triggers it unless you tell it to which means you may not see an error if you're making a windows forms application to launch your roms, you should really use a combobox (dropdown) instead of a textbox and retrieve a list of roms from a selected folder that way it fills in the right name for you
The Joker
The JokerOP2y ago
listbox roms name
The Joker
The JokerOP2y ago
saltypatron.eth
ahh, so it's value is still called Text
The Joker
The JokerOP2y ago
yes, with another emulator that doesn't need the command line it works fine, but the other emulators don't meet what I need
saltypatron.eth
well i think my questions are still valid are you getting friendly names as the name? are your arguments in the right order? is your path being combined (use Path.Combine(A, B, C)...) properly? can you get it to run with the output command from a terminal instead of through your app? Instead of Process.Start, do Console.WriteLine
The Joker
The JokerOP2y ago
can i send my project for you to look at?
saltypatron.eth
no lets solve this in a real world fashion your coworkers might have access to github but most of the time they wont have the bandwidth to look im just giving you ideas on how you can debug and step through and figure out where exactly it breaks you say the emulator launches but no game... that means you gave it a bad file name or something to that effect...
The Joker
The JokerOP2y ago
I will try to run in the console
saltypatron.eth
is the path to the rom as the argument an actual path? are there spaces in the path and if so, are they surrounded with quotes? yeah, thats your problem string commandline = string.Format("-L \"{0}\" \"{1}\"", @"EMULATOR\Sega Genesis\cores\genesis_plus_gx_libretro.dll", rom); you need to wrap your arguments in quotes when they have spaces "Sega Genesis" im actually working on building a 68000 MPU computer on a breadboard... it's the processor that powered the genesis
The Joker
The JokerOP2y ago
yes
string rom = @"C:\Users\arthu\Desktop\FrontEndGames\FrontEndGames\bin\Debug\ROMS\Sega Genesis\" + lsbRoms.Text + ".zip";
string emulator = @"EMULATOR\Sega Genesis\retroarch.exe";
string commandline = string.Format("-L \"{0}\" \"{1}\"", @"C:\Users\arthu\Desktop\FrontEndGames\FrontEndGames\bin\Debug\EMULATOR\Sega Genesis\cores\genesis_plus_gx_libretro.dll", rom);

//string commandline = string.Format("-L \"{0}\" \"{1}\"", @"EMULATOR\Sega Genesis\cores\genesis_plus_gx_libretro.dll", rom);

if (!File.Exists(emulator))
{
MessageBox.Show("Emulator is required to continue.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

else
{
Process.Start(emulator, "\"" + commandline);
}
string rom = @"C:\Users\arthu\Desktop\FrontEndGames\FrontEndGames\bin\Debug\ROMS\Sega Genesis\" + lsbRoms.Text + ".zip";
string emulator = @"EMULATOR\Sega Genesis\retroarch.exe";
string commandline = string.Format("-L \"{0}\" \"{1}\"", @"C:\Users\arthu\Desktop\FrontEndGames\FrontEndGames\bin\Debug\EMULATOR\Sega Genesis\cores\genesis_plus_gx_libretro.dll", rom);

//string commandline = string.Format("-L \"{0}\" \"{1}\"", @"EMULATOR\Sega Genesis\cores\genesis_plus_gx_libretro.dll", rom);

if (!File.Exists(emulator))
{
MessageBox.Show("Emulator is required to continue.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

else
{
Process.Start(emulator, "\"" + commandline);
}
same problem with full path Top Thanks @saltypatron.eth, now worked fine.
private void StartGame()
{
ProcessStartInfo startInfo = new ProcessStartInfo();

string pathRoms = ini.IniReadValue("ROMPATH", "Sega Genesis");
string romname = lsbRoms.Text;
string extensionRom = ini.IniReadValue("EXTENSION", "Sega Genesis");
string rom = pathRoms + romname + extensionRom;
string emulator = ini.IniReadValue("EMULATOR", "Sega Genesis");
string core = ini.IniReadValue("CORE", "Sega Genesis");

startInfo.FileName = emulator;
startInfo.Arguments = string.Format("-L \"{0}\" \"{1}\"", core, rom);

Process.Start(startInfo);
}
private void StartGame()
{
ProcessStartInfo startInfo = new ProcessStartInfo();

string pathRoms = ini.IniReadValue("ROMPATH", "Sega Genesis");
string romname = lsbRoms.Text;
string extensionRom = ini.IniReadValue("EXTENSION", "Sega Genesis");
string rom = pathRoms + romname + extensionRom;
string emulator = ini.IniReadValue("EMULATOR", "Sega Genesis");
string core = ini.IniReadValue("CORE", "Sega Genesis");

startInfo.FileName = emulator;
startInfo.Arguments = string.Format("-L \"{0}\" \"{1}\"", core, rom);

Process.Start(startInfo);
}
topic close.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server