Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by eem · Aug 30, 2011 at 12:45 AM · startosxprocessargument

How to use Process.Start() with arguments on OSX in an EditorWindow?

Process.Start works great on windows, and very simply as well. But it seems a bit funkier on OSX.

I got it working to just launch an application normally. But I cannot figure out how to get it to launch an application with arguments on OSX. More specifically I am trying to launch a command line application with arguments. How do I do that??

I've already tried this: Process p = System.Diagnostics.Process.Start(new ProcessStartInfo(info.FullName, " -fOGLPVRTC4 -q5 -pvrtciterations8 -i" + filePaths[i] + " -o" + filePaths[i]) { UseShellExecute = false });

it throws a win32 exception

I found the tip to add '{ UseShellExecute = false }' as I did there on some other mono mac forum. So I put it in there, if you leave that line out however it does nothing.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by gamesbyangelina · Jun 24, 2013 at 01:52 AM

This is an old question but comes up prominently in Google. I want to offer an answer! I was trying to execute a command which aliased to another binary somewhere in my Mac. What I ended up doing was explicitly writing in the path to the binary. i.e. instead of:

 Process p = new Process();
         p.StartInfo.FileName="inkscape";

We have:

 Process p = new Process();
         p.StartInfo.FileName="/Applications/Inkscape.app/Contents/Resources/bin/inkscape";


I hope this helps some people as this was driving me nuts.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Neogene · Oct 13, 2013 at 08:32 AM 0
Share

It works but doesn't seem to work with processes outside Applications folder, probably due to user permissions.

i've tried calling openDiff without success, it's a symbolic link to xcrun which is inside /usr/bin.

avatar image
1

Answer by Inhuman Games · Feb 06, 2014 at 10:23 AM

Did you try inserting "--args " at the beginning of your arguments string? This solved the issue for me.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ZeraKoN · Jun 16, 2016 at 05:02 AM 0
Share

Thank you!

avatar image
0

Answer by DanDixon · Sep 22, 2011 at 09:27 PM

This may not be helpful, but you could try this method to add arguments and set properties:

 Process p = new Process();
 p.StartInfo.FileName=command;
 p.StartInfo.Arguments = arguments;            
 p.StartInfo.RedirectStandardError=true;
 p.StartInfo.RedirectStandardOutput=true;
 p.StartInfo.CreateNoWindow=true;
 p.StartInfo.WorkingDirectory=Application.dataPath+"/..";
 p.StartInfo.UseShellExecute=false;
 p.Start();

I had problems getting Process to work at all until I used this method.

Note that not all of that is required. This works too:

 Process p = new Process();
 p.StartInfo.FileName=command;
 p.Start();

And at the top of the cs file, add this:

 using System.Diagnostics;

As discovered in this Unity forum thread about System.Diagnostics.Process.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Caiuse · Oct 02, 2012 at 08:56 AM 0
Share

I Can't get this to work on OSX, it doesn't throw an error just does nothing. Any reason that might be?

avatar image
0

Answer by robertono · Jan 11, 2016 at 03:29 PM

Guys, I have been able to launch .app using Process.Start with UseShellExecute=TRUE, and not only from Applications folder. Specifficaly in inside my app: MyApp.app/Contents/Resources/ProcessStart.app

I don't know how it was before, but in Unity 5 it works great!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Open Terminal window for OSX System.Diagnostics.Process 0 Answers

Run Terminal Command using System.Diagnostics.Process not working on osx 2 Answers

Initialising List array for use in a custom Editor 1 Answer

Start() being called more than Once?!? 3 Answers

How to delay Update() until Start() has finished? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges