取出当前脚本所在位置、文件名

 

 1 #分别取出当前脚本的父目录、文件名
 2 $Currentpath1    = Split-Path -parent $MyInvocation.MyCommand.Definition 
 3 $Currentpath2    = Split-Path -leaf $MyInvocation.MyCommand.Definition 
 4 write-host $Currentpath1 
 5 write-host $Currentpath2
 6 #取当前脚本全路径
 7 #write-host $MyInvocation.MyCommand.Definition 
 8 
 9 #功能同上
10 $Currentpath3    = Split-Path -parent $MyInvocation.MyCommand.Path
11 $Currentpath4   = Split-Path -leaf $MyInvocation.MyCommand.Path

 

你可能感兴趣的:(脚本)