Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use Process.Start() or equivalent with Mono on a Mac and pass in arguments
    text
    copied!<p>I am trying to write some c# code to start a browser using <code>Process.Start(app,args);</code> where apps is the path to the browser e.g. <code>/Applications/Google Chrome.app/Contents/MacOS/Google Chrome</code> and the args are <code>--no-default-browser-check</code></p> <p>If i do, which works on Windows and on Linux</p> <pre><code>Process.Start("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","--no-first-run"); </code></pre> <p>I get</p> <pre><code>open: unrecognized option `--no-first-run' Usage: open [-e] [-t] [-f] [-W] [-n] [-g] [-h] [-b &lt;bundle identifier&gt;] [-a &lt;application&gt;] [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. </code></pre> <p>I have also tried <a href="http://www.monobjc.net/" rel="noreferrer">Monobjc</a> to try run the code with </p> <pre><code>// 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(); </code></pre> <p>But when I run my code using NUnit it causes NUnit to blow up.</p> <p>I suspect that this is a bug but can't prove it. I appreciate any and all help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload