Created
July 20, 2017 16:29
-
-
Save cat2151/48c1bb91558369815f6ddc06177380df to your computer and use it in GitHub Desktop.
batファイル内のPowerShell内のJScript.NET(≒JavaScript)プログラムを動かす
This file contains 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
@powershell -NoProfile -ExecutionPolicy Unrestricted "$s=[scriptblock]::create((gc \"%~f0\"|?{$_.readcount -gt 1})-join\"`n\");&$s" %*&goto:eof | |
# http://qiita.com/cd01/items/82829ba0ec0f59e1b04d | |
# http://winscript.jp/powershell/221 | |
Param($argBat) | |
$src = @' | |
static function helloFunc(arg) { | |
var msg = "hello " + arg + " world"; | |
Console.WriteLine(msg); | |
return msg; | |
} | |
'@ | |
$JScNet = (Add-Type -Language JScript -MemberDefinition $src -Name "JScNet" -PassThru)[1] | |
$helloResult = $JScNet::helloFunc($argBat) | |
Write-Output -InputObject $helloResult | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment