我想用posh脚本自动打开ISE中的最后一个opend文件,因此我尝试保存这些文件的文件路径,如下所示。如何打开ISE中最后打开的文件的起始
$action = { $psISE.CurrentPowerShellTab.Files | select -ExpandProperty FullPath | ? { Test-Path $_ } |
Set-Content -Encoding String -Path$PSHOME\psISElastOpenedFiles.txt
Set-Content -Encoding String -Value "Now exiting..." -Path c:\exitingtest.log
}
Register-EngineEvent -SourceIdentifier Exit -SupportEvent -Action $action
,exitingtest.log创建,并已 “现在退出...”, 但不创建psISElastOpenedFiles.txt。 ISE似乎在执行退出事件之前关闭所有打开的文件。
我应该使用Timer事件吗?