当前执行powershell脚本的路径 [英] Path of currently executing powershell script

查看:45
本文介绍了当前执行powershell脚本的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 PowerShell 中执行此操作.在批处理文件中,我会这样做:%~d0%~p0

How do I do this in PowerShell. In a batch file I would do: %~d0%~p0

推荐答案

对于 PowerShell 3.0 用户 - 以下适用于模块和脚本文件:

For PowerShell 3.0 users - following works for both modules and script files:

function Get-ScriptDirectory {
    Split-Path -parent $PSCommandPath
}

这篇关于当前执行powershell脚本的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆