cmd - 将命令行参数传递给 HTA 应用程序
问题描述
我有一个想从命令提示符运行的 HTA 应用程序。我已经尝试了我能想到的所有方法,但它不起作用!它只是启动应用程序,仅此而已。
从命令提示符中,我使用完整路径运行它:
C:\users\xxx\script.hta "arg1" "arg2"
这基本上是我在这里想要完成的?
我在这里浏览了许多类似问题的页面,但我想我只是没有正确地将它们组合在一起!
这是代码:
<html>
<head>
<HTA:Application
ID="oHTA"
APPLICATIONNAME="MSI-BUILD"
Border = "NO"
Singleinstance ="YES"
BorderStyle = "Complex"
ShowInTaskBar = "YES"
MaximizeButton = "No"
MinimizeButton = "No"
scroll="NO"
VERSION="2"
/>
<script language = "VBScript">
Sub RunProgram
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
strCurDir= WshShell.CurrentDirectory
StrARG = MSINAME.value
StrARG3 = FPath.value
strFolder = "D:\SMPSS\PROJECTS\"&MSINAME.value
Set oFSO = CreateObject("Scripting.FileSystemObject")
If Not oFSO.FolderExists(strFolder) Then
oFSO.CreateFolder strFolder
End If
objShell.Run "D:\SMPSS\MSI-2\1-newproject.vbs " & StrARG , 0, True
window.close()
End Sub
Sub Window_onLoad
Self.Resizeto 890, 300
document.title = oHTA.applicationName & " v" & oHTA.version
arrCommands = Split(oHTA.commandLine, chr(34))
For i = 3 to (Ubound(arrCommands) - 1) Step 2
Select Case arrCommands(i)
Case "arg1"
myarg1 = "This is argument 1."
Case "arg2"
myarg2 = "This is argument 2."
End Select
Next
MsgBox myarg1
MsgBox myarg2
End Sub
</script>
</head>
<body style="background-color: #b2b2f4">
<td>MSI-NAME:</td>
<td> </td>
<td style="overflow:hidden">
<td style="resize:none">
<td style="text-align:right">
<td style="width: 325px"><input type = "text" name = "MSINAME" id = "MSINAME" size="50" /></td>
<p>
<td>PATH:</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td style="overflow:hidden"></td>
<td style="resize:none"></td>
<td style="text-align:right"></td>
<td style="width: 325px"><input type = "text" name = "FPath" id = "FPath" value ="" size="50" /></td>
<td> </td>
</p>
<p>
<input id='submit' type="button" value="Submit" onClick="RunProgram"></td>
</p>
</body>
</html>
解决方案
我发现问题出<meta http-equiv="x-ua-compatible" content="ie=9">
在我的代码中,一旦删除一切都开始工作,应该感谢!此外,该文件未保存为 ANSI,因此存在无效字符错误。现在一切都很好!
推荐阅读
- javascript - 用于多个输入字段的虚拟键盘
- laravel - 在 Laravel - 使用 ubuntu 16.04 在 xampp 上找不到驱动程序
- npm - 使用 NPM 安装 NuxtJS - 为什么有这么多已弃用的包?
- arrays - 根据条件使用可选元素初始化数组
- node.js - FCM向nodeJS Google Cloud Function中的多个设备(不同用户)sendMulticast与sendToDevice推送通知?
- javascript - Analytics 被浏览器阻止时的出站链接
- mysql - JSON全文搜索mysql
- reactjs - 如何在激活联系表单字段的管理对话框中使某些值成为默认值并启用和其他没有默认值和禁用
- sql - 上次观察结转查询(SELECT from-between 不完整的时间序列)
- c# - 在 C# 中动态更改数据成员的名称