通PowerShell的变量批处理脚本

问题描述:

这里是PowerShell脚本通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 [email protected],[email protected] -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 [email protected],[email protected] -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 

的价值在你的PowerShell脚本,添加$a作为参数传递给批处理文件:

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

在你的批处理文件中引用参数为%1

blat -s "Daily Report %1" -i "Our Team" -to [email protected],[email protected] -body "Please see attached." -priority 1 -attach D:\Script\Daily_Report.xlsx