Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Last active March 10, 2022 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kou1okada/10b1da66690dfc852740c07d44d0dcfb to your computer and use it in GitHub Desktop.
Save kou1okada/10b1da66690dfc852740c07d44d0dcfb to your computer and use it in GitHub Desktop.
shebang4powershell.bat - shebang for PowerShell by Batch file.
<# ::
@REM shebang4powershell.bat - shebang for PowerShell by Batch file.
@REM Copyright 2022 (c) Koichi OKADA. All rights reserved.
@REM This script is destributed under the MIT license.
@REM References:
@REM https://qiita.com/earthdiver1/items/cab769aad623a03a0f2d
@REM https://stackoverflow.com/q/2609985
@
@SETLOCAL
@SET ARGS=%*
@IF DEFINED ARGS SET ARGS=%ARGS:"=\"%
@SET INIT=echo """"`$PSCommandPath=`'%~f0`';`$PSScriptRoot=`'%~dp0`'.TrimEnd(`'\`');""""
@powershell -Command "&([scriptblock]::Create((&{%INIT%;gc '%~f0'|Out-String})))" %ARGS%
@EXIT /B %ERRORLEVEL%
#>
# Write PowerShell Script under here.
'$PSCommandPath = "{0}"' -f $PSCommandPath
'$PSScriptRoot = "{0}"' -f $PSScriptRoot;
$args |% { '$args[{0}] = "{1}"' -f $i++, $_ }
exit $args.count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment