Monday, December 13, 2010

Getting current directory of the script in PowerShell

Amazing I could find a fast solution for the question “How do I get the current directory of where I run the script”?

The solution is to use like dos command %dp0 but in powershell / .NET syntax:

$currentDirectory = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)

This does the job very nicely but if you have better way please tell me

0 comments: