批处理之家's Archiver

CrLf 发表于 2014-8-17 18:59

HTA文件去除html控件认证和接收命令行参数

[i=s] 本帖最后由 CrLf 于 2014-8-17 19:39 编辑 [/i]

以下代码为转载,可能是出自 vbs小铺,但找不到原链接
脚本之家还是叫无耻到家好了,除非被人投诉,否则转载从不注明出处,不但经常改标题还故意把代码中原有的一些字符串替换成自家域名,极度反感,强烈鄙视
-----------------------------------------------------------------------------------------------------------------------------
最近看vbscript程序员参考手册第三版,讲到hta的两个应用

[b][size=5]一是利用hta 去掉htm的控件验证 [/size][/b]
hta1的代码如下:[code]<html>
<head>
<title>Sample HTML Application one</title>
</head>
<body onload="Viewer.document.location.href='activexcontrol.htm'">
<iframe id="Viewer" application="yes"><!--这里是去掉验证的关键-->
</iframe>
</body>
</html> [/code]activexcontrol.htm代码如下:[code]<script language="VBSCRIPT">
Dim FileSystem
' Creates the FileSystemObject
Set FileSystem = CreateObject("Scripting.FileSystemObject")
</script> [/code]这样就可以去掉htm的本地验证了。
[b][size=5]二、hta接收命令行参数 [/size][/b]
书中的代码我估计有错,不可能成功,我研究了一下,hta2应当这样写:[code]<HTA:APPLICATION
ID="MySampleHTA"
Caption="yes">
<html>
<head>
<title>Sample HTML Application two</title>
</head>
<body>
<script language="VBScript">
cmdLineArray = Split(MySampleHTA.commandLine)‘这是把命令中的参数变成数组
MsgBox cmdLineArray(UBound(cmdLineArray)) '接收最后一个参数
a=document.getElementById("MySampleHTA").commandLine '这样写法是一个字符串,不是数组
MsgBox TypeName(a)&"--"&a '验证
</script>
</body>
</html> [/code]在命令行下:hta2 lcx 就会弹出lcx的对话框

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.