Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Convert VBS to an HTA

$
0
0

I have a simple vbscript to change computer name during the OS deployment:

OnErrorResumeNext
Dim objWMIService
Dim colItems
Dim colBattery
Dim objSMSEnv
Dim strNewName

Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Bios")
Set colBattery = objWMIService.ExecQuery("SELECT * FROM Win32_Battery")

'Promt for Site Code
strSite = InputBox("Enter the Site Code:") 

' Get the Serial Number
ForEach objItem In colItems
    ' Remove all beginning, trailing and containing spaces and change to all upper case
    strNewName = UCase(Trim(Replace(objItem.SerialNumber, " ", "")))
Next   

strNewName = Right(strNewName, 5)

'Site Code + Last 5 of Serial Number
strNewName = strSite & strNewName

' Set the Environment Variable that controls the Computer Name
Set objSMSEnv = CreateObject("Microsoft.SMS.TSEnvironment")
objSMSEnv("OSDCOMPUTERNAME") = strNewName

I would like to convert this into HTA. This would be first one for me. I need some help converting and how would i run an HTA?

Thanks for the help.


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>