我想在cmd
脚本中将这一长行更改为多行。
powershell.exe -Command "Send-MailMessage -To 'pwatson@company.com' -From 'pwatson@company.com' -Subject 'Standard Extract Request' -SmtpServer 'mail.company.com' -Attachment 'file.txt'"
使用cmd
行继续符“^”不起作用。同样,使用powershell
行继续符“”“也会失败。
这不起作用
powershell.exe -Command "Send-MailMessage ^
-To 'pwatson@company.com' ^
-From 'pwatson@company.com' &
-Subject 'Standard Extract Request' ^
-SmtpServer 'mail.company.com' ^
-Attachment 'file.txt'"
答案 0 :(得分:1)
只需删除"在命令周围改变&通过^测试,像这样:
private boolean checkPos(String c) {
int newPosX, newPosY;
switch(c.toUpperCase().charAt(0)){
case 'W':
newPosX = oldPosX + 1;
break;
case 'A':
newPosY = oldPosY() - 1;
break;
case 'S':
newPosX = oldPosX() - 1;
break;
case 'D':
newPosY = oldPosY() + 1;
break;
default:
//throw exception???
return false;
}
System.out.println("input:" + c.toUpperCase().charAt(0));
System.out.println("OLD POSITION: (" + oldPosY() + ";" + oldPosX() + ")");
System.out.println("NEW POSITION: (" + newPosY + ";" + newPosX + ")");
}
答案 1 :(得分:0)
Send-MailMessage `
-To 'pwatson@company.com' `
-From 'pwatson@company.com' `
-Subject 'Standard Extract Request' `
-SmtpServer 'mail.company.com' `
-Attachment 'file.txt'
并运行该文件:
powershell.exe -File "C:\path\to\your.ps1"