BAT, vbs, JS native Mix (a bat can execute VBS,JS code) _dos/bat

Source: Internet
Author: User
Tags function definition goto

found that Mshta will file://protocol to the file as HTML to resolve (note: IUnknown and Happyxxdhaha to remind you must use the absolute path, otherwise will not execute), the heart immediately have 10,000 grass mud horse ran, so the simple answer is around, And I missed four years.

Basic framework:

Copy Code code as follows:

<!--: Bathome
@echo off
Echo I ' m batch!
Mshta "File://%~f0"
Pause&exit
Use the comment label to include the batch section, provided that the Terminator of the annotation label is not present in the batch section
-->
<script language=vbs>
Msgbox "I ' m vbscript!"
</script>
<script>
Alert ("I ' m javascript!")
</script>
<script>close () </script>

In fact, the FILE://protocol name can be omitted, and if you do not need to ignore the interface, you can not use the annotation tag:

Copy Code code as follows:

@echo off
Echo I ' m batch!
Mshta "%~f0" <nul
Pause&exit
The batch section should be followed by a number of more than the previous < more, mshta to distinguish which is the label
And when you get redirected input from a file, it's recommended to add double quotes, such as < script
>>>>>>>>>>>>>>
<script language=vbs>
Msgbox "I ' m vbscript!"
</script>
<script>
Alert ("I ' m javascript!")
</script>
<script>close () </script>

Another way to use Goto may be more intuitive:

Copy Code code as follows:

@goto: Bat
<script language=vbs>
Msgbox "I ' m vbscript!"
</script>
<script>
Alert ("I ' m javascript!")
</script>
<script>close () </script>
: Bat
@echo off
Echo I ' m batch!
Mshta "%~f0" <nul
Pause&exit

Note that the host here is Mshta, so the methods and properties of the WSH host are not supported (the alternatives to some properties or methods are detailed in the following text)
But! Mshta is not good!
Native support settimeout
Native support IFRAME
Native support Dom
Native support JavaScript, VBScript barrier-free interaction
Native Support Ajax
Native support loading external scripts
Native support Select files in a window
Native support for complex page interactions
...
With so many conveniences, what's the matter?
Starting at a batch home
------------------------------------------------------------------------------------------------------------
Some knowledge about the Mshta host, refer to: https://msdn.microsoft.com/en-us/library/ms536495 (vs.85). aspx
Thanks to Xiaopo literacy, just know that the alliance has already appeared mshta the embryonic form of the plan: http://cndos.fam.cx/forum/viewthread.php?tid=39655, looking back on camera like a station search, to see if there is further development

Copy Code code as follows:

:<!--
::::,:::::;:: £ º;:;;:; BAT:::;::::::::::,-----

::::::: 1. BAT code before executing HTML code:::::::
@echo off
Call:e starting Mshta ...
Pause
::::::: 1. BAT code before executing HTML code:::::::

:: Executing HTML code:
Start Mshta%0

To::::::: 2. After executing the HTML code, the Bat code:::::::
Call:e Mshta is executing HTML codes ...
Pause
To::::::: 2. After executing the HTML code, the Bat code:::::::

:: 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 {s11ss@www.cn-dos.net/forum 2008-4-22}
Idea: When this file is executed as a bat file, it exits when it is not executed to the part of the HTML code;
When this file is executed as an HTML file, the bat code is partially annotated and will not be executed.
-->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.