3テラバイト

プログラム関連備忘録サイト。主にゲーム。

PowerShell Unity

UnityでPowerShellの実行結果を取得する

投稿日:

以下の例ではGet-ChildItemコマンドレットを引数なしで実行、標準出力への出力をDebug.LogでUnityコンソールに出力しています。

System.Diagnostics.ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo()
{
    FileName = "powershell.exe",
    Arguments = "Get-ChildItem",
    CreateNoWindow = true,
    UseShellExecute = false,
    RedirectStandardOutput = true,
    RedirectStandardError = true,
    StandardOutputEncoding = System.Text.Encoding.GetEncoding(932),
};

System.Diagnostics.Process process = System.Diagnostics.Process.Start(processStartInfo);
string standardOutput = process.StandardOutput.ReadToEnd();
string standardError = process.StandardError.ReadToEnd();
int exitCode = process.ExitCode;
process.Close();

Debug.Log(standardOutput);

-PowerShell, Unity


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


reCaptcha の認証期間が終了しました。ページを再読み込みしてください。

関連記事

no image

PowerShellでWindows Management Instrumentation (WMI)オブジェクトを取得するコマンドレットGet-WmiObjectの使い方

こんにちは、今日はPowerShellでWindows Management Instrumentation (WMI)オブジェクトを取得するコマンドレットGet-WmiObjectの使い方についてま …

no image

PowerShellの論理演算子一覧

確認環境 PSVersion 5.1.18362.1110 演算子他言語の演算子説明-not!否定!!否定-and&論理積-or|論理和-xor^排他的論理和 リンク if ステートメントにつ …

no image

現在実行中のタスク一覧をtasklistで取得する

確認環境 PowerShell 5.1 使い方 tasklist リンク tasklist | Microsoft Docshttps://docs.microsoft.com/ja-jp/windo …

no image

Unity2020でMapboxを使用する

この記事ではエラー回避のため、SDKからAR関連パッケージを除外してインポートを行います。セットアップ完了まで動作確認済ですが、AR以外にも動作に影響している可能性があります。 確認環境 Unity …

no image

PowerShellで実行ポリシーを設定するコマンドレットSet-ExecutionPolicyの使い方

こんにちは、今日はPowerShellで実行ポリシーを設定するコマンドレットSet-ExecutionPolicyの使い方についてまとめていきます。 確認環境 PSVersion 5.1.18362. …