强制字符串为大写

时间:2017-05-12 16:58:37

标签: string vbscript case-sensitive

我有一个脚本,我需要输入的文字发送大写。现在我已经想出了如何在键入时使其显示为大写,但它不会以这种方式发送。另请注意,光标一直设置在某些文本的左侧,并且在第一次按键后无法向右跳转。

代码的最后一部分是特定的输入框。 在此先感谢您的帮助!

<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>`

1 个答案:

答案 0 :(得分:5)

如果有疑问,read the documentation

  

返回已转换为大写的字符串。

所以,只需更改此行

即可
computerName = ComputerNameArea.Value

computerName = UCase(ComputerNameArea.Value)