@SetLocal EnableDelayedExpansion&Set a=%*&(if defined a set a=!a:"=\"!&Set a=!a:'=''!)&PowerShell -c $i=$input;Invoke-Expression ('$i^|^&{$PSCommandPath=\"%~f0\";$PSScriptRoot=\"%~dp0";#'+(${%~f0}^|Out-String)+'} '+('!a!'-replace'[$(),;@`{}]','`$0'))&exit/b
<#--- batch file including powershell code --------------------------------------------------#>
$strOwnRoot = $PSScriptRoot # Own Folder
$strOwnFullPath = $PSCommandPath # Own FullPath
$strOwnFileName = Split-Path -Leaf $PSCommandPath # Own File name
<#--- for coding function module below main module ------------------------------------------#>
$SKIP=$true;iex ((gc $strOwnFullPath|%{
if ($SKIP -and ($_ -notmatch "### Function Area\s*$")){return}
$SKIP=$false
$_
})-join "`r`n")
<#--- re-execute by ownself for administrator privileges -------------------------------------#>
<#
If(!(([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator"))){
If ($args[0] -eq $null) # for standard execute
{Start-Process $PSCommandPath -Verb runas}
else # for dragging other file to this file
{Start-Process $PSCommandPath -ArgumentList $args[0] -Verb runas}
Exit
}
#>
<#--- Main Module Area ----------------------------------------------------------------------#>
Set-ExecutionPolicy RemoteSigned -Scope Process
Write-Host $strOwnRoot
Write-Host $strOwnFullPath
Write-Host $strOwnFileName
Write-Host (fncGet-Date_yyyyMMdd_HHmmss)
pause
### Function Area
<#--- Function Module Area ------------------------------------------------------------------#>
function fncGet-Date{
return $ret = ((Get-Date).ToString("yyyy/MM/dd(ddd) HH:mm:ss"))
}
function fncGet-Date_yyyyMMdd_HHmmss{
return $ret = ((Get-Date).ToString("yyyyMMdd_HHmmss"))
}