$datestr = Get-Date -format yyyMMdd
$reporttype = "COMP"
$folder = "D:\reportFolder\"
$toolpath = "D:\scripts\Report.php"
$log = '{0}logs\{1}_{2}.log' -f $folder, $reporttype, $datestr
$err = '{0}logs\{1}_{2}.err' -f $folder, $reporttype, $datestr
php.exe $toolpath type=$reporttype folder=$folder >>$log 2>>$err
PowerShell ps1之語法遠優於舊有的bat,使用上更為便利與靈活、更為易讀。
直接透過PowerShell永久設定系統環境變數之指令
# example of adding a path to PATH
[System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";C:\Program Files (x86)\PHP", "Machine")
# creates “myY” of category “User”, and set the value to “"la la"”
[Environment]::SetEnvironmentVariable("myY", "la la", "User")
# removing a env var from registry
[Environment]::SetEnvironmentVariable("myY", $null, "User")
# show value of “path”
$env:path
沒有留言:
張貼留言