Ich versuche, einige C# -Code zu schreiben, um einen Browser zu starten mit Process.Start(app,args);
wo Apps ist der Pfad zum Browser z. /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
und die args sind --no-default-browser-check
Wie zu verwenden Process.Start() oder gleichwertig mit Mono auf einem Mac und Argumente übergeben
Wenn ich tun, die unter Windows und auf Linux
ich
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.
Ich habe auch versucht, Monobjc zu versuchen, führen Sie den Code mit
arbeitetProcess.Start("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","--no-first-run");
// 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();
Aber wenn ich meinen Code mit NUnit es laufen verursacht NUnit zu explodieren.
Ich vermute, dass dies ein Fehler ist, kann es aber nicht beweisen. Ich schätze jede Hilfe! so etwas wie dieses
Hat laufen diesen Befehl aus eine Befehlszeile arbeiten? – nos
Ja, es funktioniert. Von dem was ich sehen kann, sollte Process.Start() exec verwenden, um die App zu starten, anstatt – AutomatedTester
zu öffnen. Was ist mit dem Erstellen eines Skripts, das Chrome mit der gewünschten Befehlszeile ausführt und dieses Skript über Mono ausführt? – unknownuser