Skip to content

Instantly share code, notes, and snippets.

@LivingGhost
Created February 11, 2020 14:09
Show Gist options
  • Save LivingGhost/fb2ca25a94cd794d7c78fc319885d0e3 to your computer and use it in GitHub Desktop.
Save LivingGhost/fb2ca25a94cd794d7c78fc319885d0e3 to your computer and use it in GitHub Desktop.
Powershellスクリプトを呼び出そうとする度に調べるのは大変なので
@echo off
REM 引数1から*.ps1のファイルパスを取得
set PS1_FILE_PATH=%1
REM 引数1の取得に失敗した場合ユーザに入力させる
IF "%1" EQU "" (
set /P PS1_FILE_PATH="*.ps1のファイルパス:"
)
REM *.ps1ファイル呼び出し
IF EXIST "%PS1_FILE_PATH%" (
echo 実行: %PS1_FILE_PATH%
powershell -ExecutionPolicy RemoteSigned -File "%PS1_FILE_PATH%"
set CALL_RESULT=0
) ELSE (
echo ファイルパスが有効ではありません(%PS1_FILE_PATH%
set CALL_RESULT=1
)
PAUSE
REM 終了
exit /b %CALL_RESULT%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment