Vbscript 从HTA文件运行cmd

Vbscript 从HTA文件运行cmd,vbscript,scripting,cmd,hta,Vbscript,Scripting,Cmd,Hta,我是个新手,vbs和HTA命令,但我尝试创建一个简单的HTA文件夹,其中包含一些表示日期和当前时间的文本框,我需要运行一个特定的cmd命令,该命令以该日期/小时为单位,并在指定的命令中使用它们。我想当您阅读代码时,您会了解更多。我对错误提前道歉 <html> <head> <title>HTA Test</title> <HTA:APPLICATION ID="objTest" APPLICATIONNAME="HTA Test"

我是个新手,vbs和HTA命令,但我尝试创建一个简单的HTA文件夹,其中包含一些表示日期和当前时间的文本框,我需要运行一个特定的cmd命令,该命令以该日期/小时为单位,并在指定的命令中使用它们。我想当您阅读代码时,您会了解更多。我对错误提前道歉

<html>
<head>
<title>HTA Test</title>
<HTA:APPLICATION 
 ID="objTest" 
 APPLICATIONNAME="HTA Test"
 SCROLL="no"
 SINGLEINSTANCE="yes"
>
</head>

<SCRIPT LANGUAGE="VBScript">
Sub TestSub
Dim Shell
Set Shell = WScript.CreateObject ("WScript.Shell")
Shell.run WScript "cmd /g applStart.sh SetTime.dat Year.Value-Month.Value-Day.Value-          Hour.Value-Minute.Value-Second.Value"
Set Shell = Nothing
End Sub
</SCRIPT>
<body>
 Type in the date you want to jump to:</br>

<input type="number" name="Day" size="2">
<input type="number" name="Month" size="2">
<input type="number" name="Year" size="4">
<input type="number" name="Hour" size="2">
<input type="number" name="Minute" size="2">
<input type="number" name="Second" size="2">

<input id=runbutton  type="button" value="Run Script" name="run_button"   onClick="TestSub">
<SCRIPT LANGUAGE="VBScript">
Sub RunProgram 
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "C:\Users\uidv4860\Desktop\Getlogs\PuTTY\putty.exe -load EOBR"
End Sub

</SCRIPT>
<body>
Type in the date you want to jump to:</br>
Day:
<input type="int" name="fDay" size="2" maxLength="2">
Month:
<input type="int" name="fMonth" size="2" maxLength="2">
Year:
<input type="int" name="fYear" size="4" maxLength="4">
Hour:
<input type="int" name="fHour" size="2" maxLength="2">
Minute:
<input type="int" name="fMinute" size="2" maxLength="2">
Second:
<input type="int" name="fSecond" size="2" maxLength="2">
<button onclick="RunProgram">Run Program</button> <p>
</body>

HTA试验
子测试子
暗壳
Set Shell=WScript.CreateObject(“WScript.Shell”)
Shell.run WScript“cmd/g applStart.sh SetTime.dat Year.Value-Month.Value-Day.Value-Hour.Value-Minute.Value-Second.Value”
Set Shell=无
端接头
键入要跳转到的日期:

<SCRIPT LANGUAGE="VBScript">
Sub RunProgram 
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "C:\Users\uidv4860\Desktop\Getlogs\PuTTY\putty.exe -load EOBR"
End Sub

</SCRIPT>
<body>
Type in the date you want to jump to:</br>
Day:
<input type="int" name="fDay" size="2" maxLength="2">
Month:
<input type="int" name="fMonth" size="2" maxLength="2">
Year:
<input type="int" name="fYear" size="4" maxLength="4">
Hour:
<input type="int" name="fHour" size="2" maxLength="2">
Minute:
<input type="int" name="fMinute" size="2" maxLength="2">
Second:
<input type="int" name="fSecond" size="2" maxLength="2">
<button onclick="RunProgram">Run Program</button> <p>
</body>
哎,,感谢您的快速响应。我已经设法让它运行了我想要的一部分。settime.sh的部分实际上是putty中的一个命令,我在写这篇文章的时候还没有完全意识到这一点,但我已经设法让它在我按下run按钮时运行putty。现在我需要它使用文本框中的用户。这是我到目前为止得到的: HTA试验

<SCRIPT LANGUAGE="VBScript">
Sub RunProgram 
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "C:\Users\uidv4860\Desktop\Getlogs\PuTTY\putty.exe -load EOBR"
End Sub

</SCRIPT>
<body>
Type in the date you want to jump to:</br>
Day:
<input type="int" name="fDay" size="2" maxLength="2">
Month:
<input type="int" name="fMonth" size="2" maxLength="2">
Year:
<input type="int" name="fYear" size="4" maxLength="4">
Hour:
<input type="int" name="fHour" size="2" maxLength="2">
Minute:
<input type="int" name="fMinute" size="2" maxLength="2">
Second:
<input type="int" name="fSecond" size="2" maxLength="2">
<button onclick="RunProgram">Run Program</button> <p>
</body>

子运行程序
设置objShell=CreateObject(“Wscript.Shell”)
运行“C:\Users\uidv4860\Desktop\Getlogs\PuTTY\PuTTY.exe-load EOBR”
端接头
键入要跳转到的日期:
日期: 月份: 年份: 时间: 分钟: 第二: 运行程序
我在上面的陈述中看到了几个错误:

<SCRIPT LANGUAGE="VBScript">
Sub RunProgram 
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "C:\Users\uidv4860\Desktop\Getlogs\PuTTY\putty.exe -load EOBR"
End Sub

</SCRIPT>
<body>
Type in the date you want to jump to:</br>
Day:
<input type="int" name="fDay" size="2" maxLength="2">
Month:
<input type="int" name="fMonth" size="2" maxLength="2">
Year:
<input type="int" name="fYear" size="4" maxLength="4">
Hour:
<input type="int" name="fHour" size="2" maxLength="2">
Minute:
<input type="int" name="fMinute" size="2" maxLength="2">
Second:
<input type="int" name="fSecond" size="2" maxLength="2">
<button onclick="RunProgram">Run Program</button> <p>
</body>
  • 有一个虚假的
    WScript
  • CMD.EXE
    没有选项
    /g
    。你是说
    /c
  • .sh
    是一个通常用于Linux/Unix shell脚本的扩展。Windows批处理文件的扩展名为
    .bat
    .cmd
  • VBScript不会在字符串中展开变量,所以您需要将变量和字符串文本连接起来
此外,我还要将
,0,True
附加到语句中,以便
CMD
实例隐藏运行,代码等待外部命令完成

<SCRIPT LANGUAGE="VBScript">
Sub RunProgram 
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "C:\Users\uidv4860\Desktop\Getlogs\PuTTY\putty.exe -load EOBR"
End Sub

</SCRIPT>
<body>
Type in the date you want to jump to:</br>
Day:
<input type="int" name="fDay" size="2" maxLength="2">
Month:
<input type="int" name="fMonth" size="2" maxLength="2">
Year:
<input type="int" name="fYear" size="4" maxLength="4">
Hour:
<input type="int" name="fHour" size="2" maxLength="2">
Minute:
<input type="int" name="fMinute" size="2" maxLength="2">
Second:
<input type="int" name="fSecond" size="2" maxLength="2">
<button onclick="RunProgram">Run Program</button> <p>
</body>
试试这个:

<SCRIPT LANGUAGE="VBScript">
Sub RunProgram 
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "C:\Users\uidv4860\Desktop\Getlogs\PuTTY\putty.exe -load EOBR"
End Sub

</SCRIPT>
<body>
Type in the date you want to jump to:</br>
Day:
<input type="int" name="fDay" size="2" maxLength="2">
Month:
<input type="int" name="fMonth" size="2" maxLength="2">
Year:
<input type="int" name="fYear" size="4" maxLength="4">
Hour:
<input type="int" name="fHour" size="2" maxLength="2">
Minute:
<input type="int" name="fMinute" size="2" maxLength="2">
Second:
<input type="int" name="fSecond" size="2" maxLength="2">
<button onclick="RunProgram">Run Program</button> <p>
</body>
Shell.run "cmd /c applStart.cmd SetTime.dat " _
  & Year.Value & "-" & Month.Value & "-" & Day.Value & "-" _
  & Hour.Value & "-" & Minute.Value & "-" & Second.Value, 0, True

我2天前才开始学习,所以再次请原谅,代码不匹配。我尝试过批处理文件和vbs脚本,这就是为什么您看到了WScript。是的,它应该是/c,但我还是有点困惑。关于脚本,我尝试了您建议的方法,但出现了错误:参数数量错误或属性分配无效:“年”
Year
(以及
Month
Day
,…)是VBScript内置函数的名称。将输入字段的名称更改为与内置函数的名称不冲突的名称,例如,
fyear
fmonth
fday
。。。