Created
July 14, 2020 02:40
-
-
Save LivingGhost/4b5db5726a596a846d774876bb8c070b to your computer and use it in GitHub Desktop.
batファイル内で直接PowerShellのコードを実行する (さらに自身のウィンドウを非表示にする)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@(echo '> NUL | |
echo off) | |
setlocal enableextensions | |
echo %~n0%~x0 | |
if "%~1" neq "RESTARTED" ( goto RESTART ) | |
set "THIS_PATH=%~f0" | |
set "PARAM_1=%~2" | |
PowerShell.exe -Command "iex -Command ((gc \"%THIS_PATH:`=``%\") -join \"`n\")" | |
exit /b %errorlevel% | |
:RESTART | |
powershell -NoProfile -ExecutionPolicy unrestricted -Command "Start-Process \"%~f0\" -ArgumentList \"RESTARTED %~1\" -WindowStyle Hidden -Verb runas" | |
exit | |
') | sv -Name TempVar | |
# 以降にPowershellコマンドを記載していく |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment