2017-09-02 126 views
2

我想創建一個批處理文件,它將創建一個VBScript。 我試圖做這樣的事情:使用批處理文件創建一個VBScript

echo somescripthere & morehere , andhere >> hello.vbs 
pause (for debugging) 

但是當我運行的批處理文件,它與

"somescripthere" is not recognized as an internal or external command, 
operable program or batch file. 
"morehere" is not recognized as an internal or external command, 
operable program or batch file. 
"andhere" is not recognized as an internal or external command, 
operable program or batch file. 

任何迴應知道是什麼原因造成這一點,我怎麼能解決這個問題?我不擅長編碼,甚至在VBScript上更糟糕。

+0

腳本我加轉義字符我抱怨'somescripthere'而不是'morehere'? – SomethingDark

+0

它依次抱怨它們全部。 – GoldenLizardYT

+0

你爲什麼不用現實世界的VBScript命令來嘗試它。混淆這樣的例子是毫無意義的。 – Squashman

回答

1

這裏是你展示如何從一個批處理文件創建一個VBScript和cscript的引擎執行它的例子:

@echo off 
Title Typewriter with speaking voice by Hackoo 2017 
Color 0A & Mode con cols=70 lines=3 
::************************************************* 
Rem Just creating a vbscript file 
Rem to be executed with cscript engine 
(
echo strText=wscript.arguments(0^) 
echo intTextLen = Len(strText^) 
echo intPause = 150 
echo For x = 1 to intTextLen 
echo  strTempText = Mid(strText,x,1^) 
echo  WScript.StdOut.Write strTempText 
echo  WScript.Sleep intPause 
echo Next 
echo Set Voice=CreateObject("SAPI.SpVoice"^) 
echo voice.speak strText 
)>%tmp%\%~n0.vbs 
::************************************************* 
:Main 
set Msg="This is only a testing string to see if my script really works or not?" 
Call :Typewriter %Msg% 
set Msg="  This a message from a vbscript created from a batch file !" 
Call :Typewriter %Msg% 
set Msg="   I want to say Hello for everybody on Stackoverflow !" 
Call :Typewriter %Msg% 
Timeout /t 3 /nobreak>nul 
if exist "%tmp%\%~n0.vbs" Del "%tmp%\%~n0.vbs" 
Exit 
::********************************************************************* 
:TypeWriter 
Cls 
echo(
cscript.exe /noLogo "%tmp%\%~n0.vbs" "%~1" 
exit /b 
::********************************************************************* 

又如使用VBScript和批處理

@echo off 
Title Listen to the music with batch and vbscript 
mode con cols=60 lines=3 & color 9E 
echo. 
Echo To stop the music just close this window 
set "file=http://www.chocradios.ch/djbuzzradio_windows.mp3.asx" 
set "vbsfile=%tmp%\%~n0.vbs" 
( 
    echo Set Sound = CreateObject("WMPlayer.OCX.7"^) 
    echo Sound.URL = "%file%" 
    echo Sound.Controls.play 
    echo do while Sound.currentmedia.duration = 0 
    echo wscript.sleep 100 
    echo loop 
    echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000 
)>%vbsfile% 
cscript /nologo %vbsfile% 
收聽廣播電臺在線
0

你應該之前 「&」

echo somescripthere ^& morehere , andhere >> hello.vbs