简体   繁体   English

在Powershell中运行批处理文件

[英]Running a batch file in powershell

I am using the application LabTech to write scripts for Leo backup. 我正在使用应用程序LabTech编写用于Leo备份的脚本。 I have a batch file on my local C drive (backup.bat). 我的本地C驱动器(backup.bat)上有一个批处理文件。 I need that file to run when a backup fails. 备份失败时,我需要该文件才能运行。 How would I do this in powershell with commands? 我将如何在Powershell中使用命令执行此操作? I looked on Google and could not find anything concrete. 我在Google上浏览时,找不到任何具体的东西。

Any help is appreciated. 任何帮助表示赞赏。 Please let me know if you need any more information. 如果您需要更多信息,请告诉我。

You can try replacing email line (or add under it) 您可以尝试替换电子邮件行(或在其下添加)

& "path\to\your\file.bat"

if there are spaces. 如果有空格。 If not: 如果不:

path\to\your\file.bat 

尝试使用-wait开关,这样您的Powershell脚本将暂停,直到backup.bat和隐藏的开关完成,从而使其看不见地运行。

Start-Process -FilePath 'C:\Backup.bat' -Wait -WindowStyle Hidden

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM