0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Powershell > フォルダ情報を渡す > Param使用

Last updated at Posted at 2016-01-29
動作環境
Windows 8.1 pro (64bit)

ps1をバックグラウンドで実行した時に、実行場所がスクリプトのあるフォルダから変わってしまう問題の対応中。

なんらかの方法でフォルダ情報を渡さないといけない。その一つとしてParamを使用してみる。

参考 https://technet.microsoft.com/ja-jp/magazine/jj554301.aspx

Code

160130_parameter.ps1
Param(
[String]$targetDir
)

function test_parameter()
{
    $targetDir
}

function main()
{
    test_parameter
}

main
実行例
> powershell .\160130_parameter.ps1 -targetDir C:\ZyboDev\zybo_160112_baseDesign
C:\ZyboDev\zybo_160112_baseDesign

フォルダ情報を渡せた。

日常的に使う場合、フォルダを指定したバッチファイルを使うことになるのだろうか。

スコープがどれくらい広いのかは今のところよくわかっていない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?