1. ホーム
  2. スクリプト・コラム
  3. DOS/BAT

BATとHTMLのハイブリッドプログラミングの記述方法

2022-02-10 12:26:33

コアコード

:<! --
::::::::::::::::::::::::::::::::BAT::::::::::::::::::::::::::::::::

::::::::1. Execute the HTML code before the BAT code ::::::::
@echo off
call :e Starting mshta...
pause
::::::::1. Execute the BAT code before the HTML code ::::::::

::Execute HTML code.
start mshta %0

::::::::2. Execute the BAT code after the HTML code ::::::::
call :e Mshta is executing HTML codes...
pause
::::::::2. BAT code after executing HTML codes ::::::::

::Exit BAT.
exit/b

:::::::BAT function definition section :::::::
:e
echo %*
goto :eof
:::::::BAT function definition section :::::::

::::::::::::::::::::::::::::::::BAT::::::::::::::::::::::::::::::::
-->

<! -- This sentence is used to clear the first line of :-->
<script> document.body.innerText=""</script>

<! --------------------------HTML-------------------------->
<body onkeypress=window.close()>
<hr color=red>
<marquee><font color=green>HTML Codes</font></marquee>
<hr color=red>
<! --------------------------HTML-------------------------->

<! -- BAT & HTML {[email protected]/forum 2008-4-22}
Idea: when this file is executed as a BAT file, it exits before it reaches the HTML code section.
   When this file is executed as an HTML file, the BAT code section is commented out and will not be executed.
-->