windows - 在启动powershell后保持批处理脚本运行
问题描述
我正在使用批处理脚本来自动化我必须在计算机上运行的许多任务。在批处理文件中,我有一个菜单让您分别在每个任务之间进行选择或执行所有操作。当我选择做所有事情时,在启动第一个 .ps1 后,它只会杀死我的 cmd 窗口。
我找到了一些方法来保持窗口打开,但脚本没有继续......我还创建了一个“主文件”来调用所有“.ps1”并尝试了这些 cmds:call、/wait 调用功能有效并且它们一切开始。所以我不明白为什么他们会在我的脚本中做同样的事情。在我的脚本中,下面的 cmd 行不会互相吼叫,因为我希望能够单独调用它们。
我想正确运行的部分脚本:
echo Windows Layout
start /wait PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass -File ""%~dp0Customisation\Export_Import_Layout.ps1""' -Verb RunAs}"
echo Remove Unwanted Apps
start /wait PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass -File ""%~dp0Clean\RemoveAppx.ps1""' -Verb RunAs}"
wmic product where name="WinZip 22.5" call uninstall
ping -n 6 localhost >nul
Taskkill /IM /F "MicrosoftEdge.exe"
Taskkill /IM /F "MicrosoftEdgeCP.exe"
Taskkill /IM /F "MicrosoftEdgeSH.exe"
%~dp0Clean\MCPR.exe
master.bat 看起来像这样:
call PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass -File ""%~dp0InstallChocoAndApps.ps1""' -Verb RunAs}"
call PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass -File ""%~dp0Clean\RemoveAppx.ps1""' -Verb RunAs}"
任何提示都会被应用。请记住,我不是脚本专家。
谢谢
本
解决方案
设法通过添加 start "" /wait 而不是 start /wait 来解决我的问题
推荐阅读
- android - Glide for Android - 没有发出 URL 请求,也不例外
- firebase - 如何区分活跃用户和非活跃用户
- sikuli - 如何在 sikuli 脚本中实现链式搜索
- excel - Excel TFS 加载项连接到 TFS 时崩溃
- windows - Windows UWP:单进程后台蓝牙任务未触发
- java - 在java中执行“fetchall”语句的更好方法是如何在json响应中进行转换?
- html - 发布缩略图未显示在主页上并出现错误
有人可以帮忙吗?缩略图未显示在我的博客文章中,并且在检查元素中显示以下错误:找不到标签的替换 [post.thumbnailUrl]
我尝试了我的方法,但我无法成功。
如何根据
- ios - 如何根据 Swift 4 中的发件人更改在动作功能中使用的属性
- c# - 将从受约束的泛型基类继承的类分配给具有受约束的泛型的继承基类
- php - Laravel 查询构建器,使用包含和排除进行过滤