powershell - 将 powershell 变量传递给批处理脚本

标签 powershell batch-file blat

这里是powershell脚本

$a = get-date -format "MMM-d-yyyy"
Start-Process "D:\Script\send_report.bat"

send_report.bat 使用 blat 发送邮件

D:
cd "D:\Program Files (x86)\blat321\full"
blat -s "Daily Report" -i "Our Team" -to member1@team.org,member2@team.org -body "Please see attached." -priority 1 -attach D:\Script\Daily_Report.xlsx

如何将 $a 插入 send_report.bat?我想要“每日报告”旁边的 $a

最佳答案

@echo off
cd /d "D:\Program Files (x86)\blat321\full"
set "the_date=%~1"
blat -s "Daily Report" -i "Our Team" -to member1@team.org,member2@team.org -body "Please see attached." -priority 1 -attach D:\Script\Daily_Report_%the_date%.xlsx

然后像这样调用 bat :

$a = get-date -format "MMM-d-yyyy"
Start-Process "D:\Script\send_report.bat" $a

关于powershell - 将 powershell 变量传递给批处理脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26263699/

相关文章:

windows - 通过 powershell 脚本自定义协议(protocol)处理程序

windows - 在更改为cmd后的powershell中无法通过批处理脚本文件调用bat文件

java - blat 可以向其发送电子邮件的收件人数量是否有限制

powershell - PowerShell:从变量中删除或替换引号

powershell - 将 invoke 命令的输出封装在一个变量中 - PowerShell

Powershell 和 HP 标准 TCP/IP 打印机端口

entity-framework - 使用 Azure Pipeline 任务进行 EF 迁移

batch-file - 防止 "abort"在 Windows 批处理中进行 npm 安装

linux - 如何编写 Linux 脚本以从单个可执行文件运行多个文件?

linux - 安装软件 BLAT 时遇到问题