2

这是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

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

4

2 回答 2

3

在您的 PowerShell 脚本中,将$a作为参数添加到批处理文件中:

Start-Process "D:\Script\send_report.bat" $a

在您的批处理文件中,将参数引用为%1.

blat -s "Daily Report %1" -i "Our Team" -to member1@team.org,member2@team.org -body "Please see attached." -priority 1 -attach D:\Script\Daily_Report.xlsx
于 2014-10-08T18:23:44.430 回答
3
@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

并像这样称呼蝙蝠:

$a = get-date -format "MMM-d-yyyy"
Start-Process "D:\Script\send_report.bat" $a
于 2014-10-08T18:25:12.237 回答