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でWebリクエストを実行するコマンドレットInvoke-WebRequestの使い方

こんにちは、今日はPowerShellでWebリクエストを実行するコマンドレットInvoke-WebRequestの使い方についてまとめていきます。 確認環境 PSVersion 5.1.18362. …

no image

Unityでマウスオーバーしているウィンドウを最大化するショートカットキー

こんにちは、今日はUnityでマウスオーバーしているウィンドウを最大化するショートカットキーについてまとめていきます。 確認環境 Unity 2018.4.15f1 マウスオーバーしているウィンドウを …

no image

Unity – システム情報とハードウェア情報を取得する

こんにちは、今日はUnityで実行環境のOSやCPU、メモリ等のシステム情報、ハードウェア情報を取得する方法についてまとめていきます。 確認環境 Unity 2018.4.15f1 システム情報とハー …

no image

PowerShellで特定ディレクトリのファイル内文字列を置換する

Get-ChildItem . | ForEach-Object {Get-Content -Encoding utf8 $_ | ForEach-Object {$_ -creplace &#039 …

no image

Unityで使用するコンパイラーを切り替える方法

こんにちは、今日はUnityで使用するC#コンパイラーを切り替える方法についてまとめていきます。 確認環境 Unity 2018.4.15f1 設定方法 Edit > Project Settings …