VbScript hta - 按 link 打开一个新的 hta 并检索正确的文件名
VbScript hta - Open a new hta by link and retrieve correct filename
我有两个文件; “1.hta”和“2.hta”。
"1.hta" 包含一个简单的 link 到文件 "2.hta"
<a href="2.hta">2.hta</a>
"2.hta" 包含确定其自身文件名的脚本
FullName = replace(oApp.commandLine,chr(34),"") 'oApp = HT Application ID
arrFN=split(FullName,"\")
FileName = arrFN(ubound(arrFN))
SourceDir=replace(FullName,FileName,"")
"2.hta" 启动时完美运行 "stand-alone" --> FileName = 2.hta
但是,从“1.hta”通过 link 开始“2.hta”,我得到 --> FileName = 1.hta
我需要一种方法来确定正确的文件名,或者 hta 是否总是检索 first/starting 实例的文件名?
你可以这样试试:
<html>
<head>
<title>HTA Launch another HTA</title>
<HTA:APPLICATION
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
</head>
<SCRIPT Language="vbscript">
Sub Execute(File)
Dim ws
Set ws = CreateObject("wscript.shell")
ws.run chr(34) & File & chr(34)
End sub
</SCRIPT>
<body>
<h1>This is test hta 1 ONE</h1>
<a href="#" onClick="Call Execute('2.hta')">Start the HTA2</a>
</body>
</html>
我有两个文件; “1.hta”和“2.hta”。
"1.hta" 包含一个简单的 link 到文件 "2.hta"
<a href="2.hta">2.hta</a>
"2.hta" 包含确定其自身文件名的脚本
FullName = replace(oApp.commandLine,chr(34),"") 'oApp = HT Application ID
arrFN=split(FullName,"\")
FileName = arrFN(ubound(arrFN))
SourceDir=replace(FullName,FileName,"")
"2.hta" 启动时完美运行 "stand-alone" --> FileName = 2.hta
但是,从“1.hta”通过 link 开始“2.hta”,我得到 --> FileName = 1.hta
我需要一种方法来确定正确的文件名,或者 hta 是否总是检索 first/starting 实例的文件名?
你可以这样试试:
<html>
<head>
<title>HTA Launch another HTA</title>
<HTA:APPLICATION
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
</head>
<SCRIPT Language="vbscript">
Sub Execute(File)
Dim ws
Set ws = CreateObject("wscript.shell")
ws.run chr(34) & File & chr(34)
End sub
</SCRIPT>
<body>
<h1>This is test hta 1 ONE</h1>
<a href="#" onClick="Call Execute('2.hta')">Start the HTA2</a>
</body>
</html>