Ich vermisse etwas, wenn ich versuche, den folgenden einzeiligen Befehl in mehrere Zeilen zu konvertieren. Ich suchte, fand und versuchte, diese Änderung nach Powershell -Command over multiple lineFehler quoting und/oder escaping, Cmd läuft Powershell
zu modellieren, was ich vermisse? Ich habe versucht, es einfach zu testen. Ändern Sie einfach die ersten zwei (2) Zeilen in etwas, das für Ihr System geeignet ist.
=== emailtest.bat
@ECHO OFF
SET "[email protected]"
SET "SMTPHOST=imr2.nowhere.org"
SET "FN=C:\Windows\win.ini"
@ECHO ON
powershell -Command "& send-mailmessage -to "%RECIPIENT%" -from '[email protected]' -subject 'test file transfer' -SmtpServer '%SMTPHOST%' -BodyAsHTML 'The file is <a href="%FN">here</a> for you.'
powershell -noprofile -Command "&{"^
send-mailmessage -to "%RECIPIENT%"^
-from '[email protected]'^
-subject 'test file transfer'^
-SmtpServer '%SMTPHOST%'^
-BodyAsHTML 'The file is <a href="%FN%">here</a> for you.'^
"}"
=== Der Ausgang ist
C:>call emailtest.bat
12:17:24.75 C:\Users\me\t
C:>powershell -Command "& send-mailmessage -to "[email protected]" -from '[email protected]' -subject 'test file transfer' -SmtpServer 'imr2.nowhere.org' -BodyAsHTML 'The file is <a href="C:\Windows\win.ini">here</a> for you.'
12:17:27.28 C:\Users\me\t
C:>powershell -noprofile -Command "&{" send-mailmessage -to "[email protected]" -from '[email protected]' -subject 'test file transfer' -SmtpServer 'imr2.nowhere.org' -BodyAsHTML 'The file is href="C:\Windows\win.ini""}" 0</a 1>for
The system cannot find the file specified.
Die Dinge werden einfacher und einfacher, wenn Sie PowerShell direkt verwenden, anstatt PowerShell-Befehle in einem cmd.exe-Shell-Skript (Batch-Datei) zu umbrechen. –