powershell - 我正在尝试从批处理文件批处理文件运行 powershell 脚本,但它似乎终止了批处理文件
问题描述
我有一个试图在批处理文件中调用的 PowerShell 脚本。Powershell 脚本会更新一些由后续 .exe 文件使用的凭据,这些凭据会在一小时后过期。然后我想终止 PowerShell 脚本,重新启动 PowerShell 脚本,然后重新启动 .exe。这是一个重现我的问题的简单示例:
测试.bat
::@echo off
title Started at %time%
pause
Call CallPSWrapper.bat
::Never hits this pause
pause
echo call the .exe here
CallPSWrapper.bat:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle hidden -ExecutionPolicy bypass -NoProfile -File .\MyPowerShell.ps1
我的PowerShell.ps1:
Write-Output "Waiting"
Start-Sleep -Seconds 30
我最初尝试从 test.bat 调用 MyPowerShell.ps1,但尝试将其更改为由中间批处理文件调用,希望 PowerShell 只会杀死 CallPSWrapper.bat。
解决方案
推荐阅读
- java - 在Scala中,给定一个子类,如何检查它是否使用反射覆盖其父接口(在Java中定义)的默认方法?
- java - 在 AEM 中找不到 org.apache.cxf.jaxws.spi.ProviderImpl 问题
- c# - Autofac Keyed Factory:不同枚举值的相同具体实现
- javascript - React Animations - 从显示的 6 个初始徽标列表中一次仅更改一个徽标?
- c++ - 为什么我不能在派生类运算符>>中调用基类运算符>>?
- ios - 从二进制文件中破解和读取 iOS 应用程序包数据有多难?
- arrays - 为什么我的 Array 在控制台中返回 Getter & Setter?
- python - 如何在Python中将列表中的每个元素相乘
- jquery - vue.js 与 .datepicker 冲突并在更改下一个 v-model 输入后删除日期值
- node.js - Snyk 抱怨包锁中缺少 fsevents,但 fsevents 不是必需的,并且 snyk 忽略了 --strict-out-of-sync=false