-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.bat
More file actions
14 lines (12 loc) · 793 Bytes
/
template.bat
File metadata and controls
14 lines (12 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
:: This file combines a valid cmd.exe batch file with a powershell script. This
:: is a self-contained & portable way to execute a powershell script by double
:: clicking it in the windows shell. This works independently from powershell's
:: execution policy which defaults to RESTRICED (deny any script file
:: execution). See also about_Execution_Policies and Set-ExecutionPolicy.
@ECHO OFF
powershell.exe -NoProfile -Command "& { $skip = $true; $script = Get-Content '%~f0' | ?{ If ($skip) { $skip = $_ -ne ':POWERSHELL'} Else { return $true} } | Out-String; [ScriptBlock]::Create(\"`$PSScriptRoot='%~dp0'`n$script\").Invoke() }"
EXIT /B 0
:POWERSHELL
# Preserve lines above. Only Comments (lines starting with ::) may be stripped!
# Powershell code goes below.
write-host "Hello World!"