Vbscript VB脚本按enter键而不是单击按钮

Vbscript VB脚本按enter键而不是单击按钮,vbscript,return,enter,Vbscript,Return,Enter,我有一个脚本,只有一个文本框和一个按钮可以继续。现在,您必须单击按钮或按tab键,然后按enter键。如何从文本框中发送enter以继续?谢谢 另外,一个可能没有答案的附带问题。这将保存为.hta,并在Windows Sysprep进程之前运行。如果它在笔记本电脑上运行,并且在启动时盖子是关闭的,那么屏幕是完全空白的。我可以按tab+enter使其继续,就像我看到它一样,然后当它重新启动时,它会再次正常工作。任何关于它为什么是空白的想法,以及如何让它始终显示出来的想法都将不胜感激 <htm

我有一个脚本,只有一个文本框和一个按钮可以继续。现在,您必须单击按钮或按tab键,然后按enter键。如何从文本框中发送enter以继续?谢谢

另外,一个可能没有答案的附带问题。这将保存为
.hta
,并在Windows Sysprep进程之前运行。如果它在笔记本电脑上运行,并且在启动时盖子是关闭的,那么屏幕是完全空白的。我可以按tab+enter使其继续,就像我看到它一样,然后当它重新启动时,它会再次正常工作。任何关于它为什么是空白的想法,以及如何让它始终显示出来的想法都将不胜感激

<html>
<head>
<title>Sysprep Deployment</title>
<HTA:APPLICATION 
     ID="objCompDeploy" 
     APPLICATIONNAME="Sysprep Deployment"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     maximizeButton="no"
     minimizeButton="no"
     sysMenu="yes"
>
</head>
<SCRIPT LANGUAGE="VBScript">

Set WshShell = CreateObject("Wscript.Shell")

Sub Window_onLoad
window.resizeTo 400,200
ComputerNameArea.Focus
  CreateObject("WScript.Shell").SendKeys "^{Home}"

'turn off setup flag in registry so we can query wmi
WshShell.RegWrite "HKLM\SYSTEM\Setup\SystemSetupInProgress", 0, "REG_DWORD"

'query wmi for serial number
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      serialNumber = objItem.SerialNumber
   Next

'turn setup flag back on
WshShell.RegWrite "HKLM\SYSTEM\Setup\SystemSetupInProgress", 1, "REG_DWORD"

'put the serial number that was retrieved in the textbox
ComputerNameArea.Value = serialNumber

End Sub 

Sub modUnattend

run_button.Disabled = True

Set fso = CreateObject("Scripting.FileSystemObject")

base = Wshshell.ExpandEnvironmentStrings("%SystemRoot%")
unattendFile = base & "\Panther\unattend.xml"

   computerName = ComputerNameArea.Value

 Set xmlDoc = CreateObject("Microsoft.XMLDOM")
 xmlDoc.load unattendFile

 'Iterate through Unattend.xml searching for nodes and properties to replace
 Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/ComputerName")
 For each n in oNodes
  n.text = computerName
  xmlDoc.save unattendFile
 Next


'launch the continuation of setup in a hidden window and wait for return
'if we dont wait, closing mshta, closes windeploy.exe
WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True
idTimer = window.setTimeout("closeHTA", 5000, "VBScript")
End Sub

Sub closeHTA
window.close
End Sub

Sub commandLine
WshShell.Run "%WINDIR%\System32\cmd.exe", 1, True
End Sub

</SCRIPT>
<body>
<table border="0">
<tr>
<td>Computer Name:</td>
<td><input type="text" name="ComputerNameArea" size="30" maxlength="15" value="computer"></td>
</tr>
<tr>
<td>Tab then Enter to Continue</td>
</tr>
</table> 
<p align="right">
<input id=runbutton  class="button" type="button" value="Continue" name="run_button" onClick="modUnattend">
</body>

Sysprep部署
设置WshShell=CreateObject(“Wscript.Shell”)
子窗口加载
window.resizeTo 400200
计算机名称区,焦点
CreateObject(“WScript.Shell”).SendKeys“^{Home}”
'关闭注册表中的设置标志,以便查询wmi
WshShell.RegWrite“HKLM\SYSTEM\Setup\SystemSetupInProgress”,0,“REG\u DWORD”
'查询wmi以获取序列号
Const WBEMFlagReturnInstant=&h10
常量wbemFlagForwardOnly=&h20
strComputer=“”
设置objWMIService=GetObject(“winmgmts:\\”&strComputer&“\root\CIMV2”)
设置colItems=objWMIService.ExecQuery(“从Win32_BIOS中选择*”、“WQL”_
WBEMFlagReturn立即+wbemFlagForwardOnly)
对于每个对象,在colitem中
serialNumber=objItem.serialNumber
下一个
'重新打开设置标志
WshShell.RegWrite“HKLM\SYSTEM\Setup\SystemSetupInProgress”,1,“REG\u DWORD”
'将检索到的序列号放入文本框中
ComputerNameArea.Value=serialNumber
端接头
亚模块无人值守
run_button.Disabled=真
设置fso=CreateObject(“Scripting.FileSystemObject”)
base=Wshshell.ExpandEnvironmentStrings(“%SystemRoot%”)
unattendFile=base&“\Panther\unattend.xml”
computerName=ComputerNameArea.Value
设置xmlDoc=CreateObject(“Microsoft.XMLDOM”)
xmlDoc.load文件
'遍历Unattend.xml搜索要替换的节点和属性
Set oNodes=xmlDoc.documentElement.selectNodes(“/unattend/settings/component/ComputerName”)
对于oNodes中的每个n
n、 text=计算机名
xmlDoc.save文件
下一个
'在隐藏窗口中启动继续安装程序,并等待返回
'如果我们不等待,关闭mshta,关闭windeploy.exe
WshShell.Run“%WINDIR%\System32\oobe\windeploy.exe”,0,True
idTimer=window.setTimeout(“closeHTA”,5000,“VBScript”)
端接头
近距离
窗户关上
端接头
子命令行
WshShell.Run“%WINDIR%\System32\cmd.exe”,1,True
端接头
计算机名:
选项卡,然后输入以继续


我不能100%确定这是否有效,我在enter键中添加了一个EventListener,并使其在按下enter键时触发click事件

<input id=runbutton  class="button" type="button" value="Continue" name="run_button" onKeyDown="if (event.keyCode == 13){ this.click }" onClick="modUnattend">

您可以尝试键入提交而不是按钮

<input id=runbutton  class="button" type="Submit" value="Continue" name="run_button" onClick="modUnattend">