Estoy tratando de escribir algún código C# para iniciar un navegador usando Process.Start(app,args);
donde las aplicaciones son la ruta al navegador, p. /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
y los argumentos son --no-default-browser-check
Cómo usar Process.Start() o equivalente con Mono en una Mac y pasar los argumentos
si lo hago, que funciona en Windows y en Linux
Process.Start("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","--no-first-run");
me sale
open: unrecognized option `--no-first-run'
Usage: open [-e] [-t] [-f] [-W] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames]
Help: Open opens files from a shell.
By default, opens each file using the default application for that file.
If the file is in the form of a URL, the file will be opened as a URL.
Options:
-a Opens with the specified application.
-b Opens with the specified application bundle identifier.
-e Opens with TextEdit.
-t Opens with default text editor.
-f Reads input from standard input and opens with TextEdit.
-W, --wait-apps Blocks until the used applications are closed (even if they were already running).
-n, --new Open a new instance of the application even if one is already running.
-g, --background Does not bring the application to the foreground.
-h, --header Searches header file locations for headers matching the given filenames, and opens them.
también he intentado Monobjc intentar ejecutar el código con
// spin up the objective-c runtime
ObjectiveCRuntime.LoadFramework("Cocoa");
ObjectiveCRuntime.Initialize();
NSAutoreleasePool pool = new NSAutoreleasePool();
// Create our process
NSTask task = new NSTask();
NSPipe standardOut = new NSPipe();
task.StandardOutput = standardOut;
task.LaunchPath = @"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
// add some arguments
NSString argumentString = new NSString("--no-first-run");
NSArray arguments = NSArray.ArrayWithObject(argumentString);
task.Arguments = arguments;
// We should have liftoff
task.Launch();
// Parse the output and display it to the console
NSData output = standardOut.FileHandleForReading.ReadDataToEndOfFile;
NSString outString = new NSString(output,NSStringEncoding.NSUTF8StringEncoding);
Console.WriteLine(outString);
// Dipose our objects, gotta love reference counting
pool.Release();
Pero cuando ejecuto mi código usando NUnit hace que NUnit explote.
Sospecho que esto es un error pero no lo puedo probar. ¡Agradezco cualquier ayuda!
¿Se ejecuta ese comando desde una línea de comando funciona? – nos
Sí, funciona. De lo que puedo ver, Process.Start() debería usar exec para ejecutar la aplicación en lugar de abrir – AutomatedTester
¿Qué tal crear un script que ejecute Chrome con la línea de comandos deseada y ejecutar ese script a través de Mono? – unknownuser