Edit: Maintenant que je relis votre question, je ne sais pas exactement ce que vous demandez. Demandez-vous comment lancer un vbscript? Il suffit de l'enregistrer à filename.vbs
et l'exécuter avec
cscript filename.vbs
(ou cscript /nologo filename.vbs
si vous voulez éviter d'afficher cscript spam vanité de Microsoft).
D'autre part, si vous voulez intégrer dans un script batch, alors il y a beaucoup de méthodes pour le contenu faisant écho à partir d'un script de traitement par lots dans un fichier externe. La plupart des gens font juste quelque chose comme
echo Set oolApp = CreateObject^("Outlook.Application"^)>> vbsfile
ou similaire, échappant à ^
au besoin. Cependant, vous pourriez trouver this page of heredoc methods utile. Voici un exemple en utilisant hier script I helped you make:
@if (@X)==(@Y) @end /* (batch + jscript hybrid script init)
:: *** Batch script *****
@echo off
setlocal enabledelayedexpansion
set [email protected]
for /f "delims=" %%I in ('wget "%~1" -O- -q 2^>NUL ^| findstr /i "last.*updated.*as.*of"') do (
for /f "delims=" %%x in ('cscript /nologo /e:jscript "%~f0" "%%I"') do (
set /a "thirtyMinutes = 30 * 60 * 1000"
if %%x GEQ !thirtyMinutes! (
call :doEmail
)
)
exit /b
)
exit /b
:doEmail
call :heredoc vbs >email.vbs && goto endvbs
' Create email object
Set oolApp = CreateObject("Outlook.Application")
Set email = oolApp.CreateItem(0)
email.Recipients.Add("!recipient!")
' Create the body of the email
MailBody = "<^!DOCTYPE HTML PUBLIC ""-//W3C//DTD W3 HTML//EN"">"
MailBody = MailBody & "<HTML>" & vbcrlf
MailBody = MailBody & "<HEAD><TITLE>No Invoices</TITLE></HEAD>"
MailBody = MailBody & "<BODY>" & vbcrlf
MailBody = MailBody & "<B>For Your Information</B>,<BR><BR>"
MailBody = MailBody & "No invoices were issued today.<BR><BR>"
MailBody = MailBody & "</BODY></HTML>"
' Send the Email
email.Subject = "No Invoices Issued"
email.HTMLBody = MailBody
email.Send
:endvbs
cscript /nologo email.vbs
del email.vbs
goto :EOF
:: https://stackoverflow.com/a/15032476/1683264
:heredoc <uniqueIDX>
setlocal enabledelayedexpansion
set go=
for /f "delims=" %%A in ('findstr /n "^" "%~f0"') do (
set "line=%%A" && set "line=!line:*:=!"
if defined go (if #!line:~1!==#!go::=! (goto :EOF) else echo(!line!)
if "!line:~0,13!"=="call :heredoc" (
for /f "tokens=3 delims=>^ " %%i in ("!line!") do (
if #%%i==#%1 (
for /f "tokens=2 delims=&" %%I in ("!line!") do (
for /f "tokens=2" %%x in ("%%I") do set "go=%%x"
)
)
)
)
)
goto :EOF
:: *** JScript script *****/
var args = [];
for (var i=0; i<WScript.arguments.length; i++) { args.push(WScript.arguments(i)) }
var t = args.join(' ').replace(/^\s+|<[^>]+>|\s+$/g,'').replace(/\ /g, ' ').split(' ');
var h = t[4].split(':')[0];
if (/pm/i.test(t[5])) h = h * 1 + 12;
var ds = t[6] + ' ' + t[7] + ', ' + new Date().getFullYear() + ' ' + h + ':' + t[4].split(':')[1];
var diff = new Date() - new Date(ds);
WScript.echo(diff);
Je ne l'ai pas testé, mais jouer avec elle et voir ce que vous pensez.
http://stackoverflow.com/questions/9074476/is-it-possible-to-embed-and-execute-vbscript-within-a-batch-file-without-using-a/26922679#26922679 –