說明:
此教學實現在Batch檔案(.BAT)中執行Script語言程式碼(VBScript),而且無須建立臨時檔案或者外部檔案。
範例:
BAT與VBScript混合 <!-- : Begin batch script @echo off echo batch output cscript //nologo "%~f0?.wsf" //job:JS cscript //nologo "%~f0?.wsf" //job:VBS exit /b ----- Begin wsf script ---> <package> <job id="JS"> <script language="VBScript"> sub vbsEcho() WScript.Echo "VBScript output called by JScript called by batch" end sub </script> <script language="JScript"> WScript.Echo("JScript output called by batch"); vbsEcho(); </script> </job> <job id="VBS"> <script language="JScript"> function jsEcho() { WScript.Echo("JScript output called by VBScript called by batch"); } </script> <script language="VBScript"> WScript.Echo "VBScript output called by batch" call jsEcho </script> </job> </package> BAT與HTML混合 <!-- : @echo off start "" mshta.exe "%~f0" exit /b --> <html> <head><title>HTA window</title></head> <body><h1>Hello, world!</h1></body> </html>
BAT與VBScript混合
----- Begin wsf script ---> <package>
<job id="JS"> <script language="VBScript"> sub vbsEcho() WScript.Echo "VBScript output called by JScript called by batch" end sub </script> <script language="JScript"> WScript.Echo("JScript output called by batch"); vbsEcho(); </script> </job> <job id="VBS"> <script language="JScript"> function jsEcho() { WScript.Echo("JScript output called by VBScript called by batch"); } </script> <script language="VBScript"> WScript.Echo "VBScript output called by batch" call jsEcho </script> </job>
<job id="JS">
<script language="VBScript"> sub vbsEcho() WScript.Echo "VBScript output called by JScript called by batch" end sub </script> <script language="JScript"> WScript.Echo("JScript output called by batch"); vbsEcho(); </script>
<script language="VBScript">
sub vbsEcho() WScript.Echo "VBScript output called by JScript called by batch" end sub
sub vbsEcho()
WScript.Echo "VBScript output called by JScript called by batch"
end sub
</script> <script language="JScript">
WScript.Echo("JScript output called by batch"); vbsEcho();
</script>
</job>
<job id="VBS">
<script language="JScript"> function jsEcho() { WScript.Echo("JScript output called by VBScript called by batch"); } </script> <script language="VBScript"> WScript.Echo "VBScript output called by batch" call jsEcho </script>
<script language="JScript">
function jsEcho() { WScript.Echo("JScript output called by VBScript called by batch"); }
function jsEcho() {
WScript.Echo("JScript output called by VBScript called by batch");
}
</script> <script language="VBScript">
WScript.Echo "VBScript output called by batch" call jsEcho
</package>
BAT與HTML混合
<html> <head><title>HTA window</title></head> <body><h1>Hello, world!</h1></body> </html>
參考文件:
https://qa.1r1g.com/sf/ask/635213351/ https://www.dostips.com/forum/viewtopic.php?f=3&t=5543 https://qa.1r1g.com/sf/ask/181391731/#answer-395937531
https://qa.1r1g.com/sf/ask/635213351/
https://www.dostips.com/forum/viewtopic.php?f=3&t=5543
https://qa.1r1g.com/sf/ask/181391731/#answer-395937531
Jplopsoft | THI | Netlify | NeoCities | LionFree
加密工具 | 提交歸檔 | QRCODE產生器 | 密碼產生器