powershell分层脚本 - 依赖的错误代码
我已经开始使用一个名为CRONITOR的监视系统,该系统将计划执行在其EXE中包装。
cronitor.exe exec(uid for Monitor)“通往脚本/可执行文件的路径”。
除此之外,我正在努力同步一些彼此依赖的计划任务。
我遇到的问题是,由于可执行文件包装脚本/程序/任务,因此返回Windows任务调度程序的错误代码始终为0,因为它没有在其EXE中传递。
我的工作是将PowerShell脚本分层(我还没有超级精通)。
因此,动作1在该PS1脚本中调用“ StartAction.ps1”
,
启动过程“通往cronitor的路径” -ArgumentList“ Crontior” Crontior参数和PS1的路径,该路径启动EXE进行操作1“ - 等待 启动过程“通往cronitor的路径” - argumentList”越来素的参数和PS1的路径,启动Exe for Action 2”
我遇到的问题是相同的,如果该过程失败了,则试图停止计划的任务1。我需要。要通过管道将错误代码(1)传递到启动脚本,以便它知道停止。
这是可能的,还是我缺少其他解决方案?
I have started using a monitoring system called Cronitor that wraps scheduled task executions in their EXE.
Cronitor.exe exec (UID for monitor) "Path to script/executable".
Adding to that, I am working on synchronizing some of our scheduled tasks that are dependent on each other.
The problem I have is that because the executable wraps scripts/programs/tasks, the error code returned to Windows task scheduler is always 0 because it's not passed in their exe.
My work around is to layer powershell scripts (which I am not super proficient in yet).
So Action 1 calls "StartAction.ps1"
Inside that ps1 script,
Start-Process "Path to cronitor" -ArgumentList "Crontior arguments and path to ps1 that initiates exe for action 1" -Wait
Start-Process "Path to cronitor" -ArgumentList "Crontior arguments and path to ps1 that initiates exe for action 2"
The issue I am running into is the same for trying to stop the scheduled task if the process fails in action 1. I need to pass the error code (1) up through a pipeline to the initiating script so it knows to stop.
Is that even possible, or are there other solutions I am missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论