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でディレクトリを移動するコマンドレットSet-Locationの使い方

こんにちは、今日はPowerShellでディレクトリを移動するコマンドレットのSet-Locationの使い方についてまとめていきます。 確認環境 PSVersion 5.1.18362.1110 S …

no image

PowerShellでトースト通知を送る

確認環境 PSVersion 5.1.18362.1110 トースト通知を送る [Windows.UI.Notifications.ToastNotificationManager, Win …

no image

PowerShellでCSVファイルを出力する

こんにちは、今日はPowerShellでCSVファイルを出力する方法についてまとめていきます。 確認環境 PSVersion 5.1.18362.1110 CSVファイルを出力する CSVファイルを出 …

no image

PowerShellで文字列の置換をする方法

確認環境 PSVersion 5.1.18362.1171 文字列の置換 -replace 以下のように置換したい文字列のあとに-replaceとカンマの前に置き換えたい文字列を、カンマの後に置き換え …

no image

Unityで古いプロジェクトを開いた際に表示されるAPI Update Requiredダイアログ

確認環境 Unity 2019.4.28f1 表示内容 This project contains scripts and/or assemblies that use obsolete APIs.I …