强制字符串大写

Force a string to uppercase

我有一个脚本,我需要输入的文本 sent 大写。现在我已经想出如何让它在键入时显示为大写,但它不会那样发送。另请记住,光标一直设置在某些文本的左侧,并且在第一次击键后无法跳到右侧。

代码的最后一部分是具体的输入框。 提前感谢您的帮助!

<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" style="text-transform:uppercase"></td>
</tr>
<tr>
<td>Press Enter to Continue</td>
</tr>
</table> 
<p align="right">
<input id=runbutton  class="button" type="Submit" value="            Sysprep Deployment             " name="run_button" onClick="modUnattend">
</body>`

如有疑问,read the documentation

Returns a string that has been converted to uppercase.


所以,只需更改此行

computerName = ComputerNameArea.Value

computerName = UCase(ComputerNameArea.Value)