LoginSignup
8
8

More than 5 years have passed since last update.

【Windows】Unity上からコマンドプロンプトを起動したい

Last updated at Posted at 2016-07-27

はじめに

Unity上からWindowsのコマンドプロンプトを起動するにはどうすればいいのか気になったので調べてみました。

OSはWindows 10です.

ソースコード

EditorRunTerminal.cs
using UnityEditor;
using System.Diagnostics;

public class EditorRunTerminal
{
    [MenuItem("Window/Run Terminal %t")]
    static void RunTerminal()
    {
        Process p = new Process();
        p.StartInfo.FileName = System.Environment.GetEnvironmentVariable("ComSpec");
        p.StartInfo.Arguments = "/k cd Assets";
        p.Start();
    }
}

結果

Ctrl + Tを押すとコマンドプロンプトが起動します
image

参考

外部アプリケーションを起動する、ファイルを関連付けられたソフトで開く
http://dobon.net/vb/dotnet/process/shell.html

DOSコマンドを実行し出力データを取得する
http://dobon.net/vb/dotnet/process/standardoutput.html

コマンドプロンプト起動時のオプション一覧(windows)
http://blog.layer8.sh/ja/2011/12/16/%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%83%97%E3%83%AD%E3%83%B3%E3%83%97%E3%83%88%E8%B5%B7%E5%8B%95%E6%99%82%E3%81%AE%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3/

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8