/build/static/layout/Breadcrumb_cap_w.png

K2000: Pre-Installation HTA help

Hi Everyone,
 I am trying to create a Pre-installation HTA so that our techs can select the proper Software needed for each deployment. I was able to get my software installs to export to a BAT that can be grabbed later. However, I am having trouble with uniquely naming the file so that it can be recognized during Post install. I was hoping someone could point out a good piece of VB that could help me uniquely name the file and retrieve it during Post-Install.  I am not sure if this should be done with the MAC address, IP, Computer name, etc. Any help is appreciated!

0 Comments   [ + ] Show comments

Answers (2)

Posted by: anonymous_9363 8 years ago
Red Belt
1
If you have retained the Windows Scripting Host on your systems, you should have the Scriplet.Typelib object registered. This has a method for generating GUIDs:

Option Explicit

Dim objTypeLib
Dim strGUID
Dim objIE

'// Create the object
Set objTypeLib = CreateObject("Scriptlet.TypeLib")

'// Test that the object was created successfully
If Not IsObject(objTypeLib) Then
'// Post/log some error message, then exit
WScript.Quit(False)
End If

'// Have the Type Library generate a GUID
strGUID = objTypeLib.Guid

'// Create an IE object - this is only so that we can use the clipboard to contain the GUID
Set objIE = CreateObject("InternetExplorer.Application")
If Not IsObject(objIE) Then
'// Post/log some error message, then exit
WScript.Quit(False)
End If

With objIE
.Navigate("about:blank")
.document.parentwindow.clipboardData.SetData "text", strGUID
.Quit
End With

'// Clean up
Set objTypeLib = Nothing
Set objIE = Nothing


Comments:
  • Awesome! Will the GUID stay the same from the Windows PE environment to the Post Imaged (Win 7) Environment? - anonymous_128529 8 years ago
    • Every time you ask for a GUID it will different and statistically univoque.
      So you need to make a note of the GUID somewhere.
      You can use the network drive T: inside the KBE that is mapped to \\yourappliance\petemp to write the file(s).
      If you want to univocally identify the machine you can 'carve' the MAC address of the NIC and use it for files/folders name to store in the T: drive.
      I can provide a script to grab the MAC address of the machine if you like.
      Regards,
      Marco - StockTrader - StockTrader 8 years ago
      • If you have an example of a script to grab the MAC that would be very helpful. Thank you - anonymous_128529 8 years ago
    • Here we go :-)

      'Get mac address
      wmiQuery = "Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True"

      Set objWMIService = GetObject("winmgmts:\\")
      Set colItems = objWMIService.ExecQuery(wmiQuery)

      For Each objItem in colItems
      macAddress = objItem.MACAddress
      macAddress = Trim(macAddress)
      macAddress = replace(macAddress, ":","")
      '
      '
      kind regards,
      Marco -StockTrader - StockTrader 8 years ago
      • I got it to work but that was only by trial and error. I was hoping you could let me know if this is correct or if I need to change it. The Sub is so that I could run it using a button. Thanks in advance


        <SCRIPT language="vbscript">

        wmiQuery = "Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True"

        Set objWMIService = GetObject("winmgmts:\\")
        Set colItems = objWMIService.ExecQuery(wmiQuery)

        For Each objItem in colItems
        macAddress = objItem.MACAddress
        macAddress = Trim(macAddress)
        macAddress = replace(macAddress, ":","")
        next

        EthMAC = macaddress

        Sub Runscript
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set wshShell = CreateObject("WScript.Shell")
        Set InstallerFile = fso.CreateTextFile ("c:\test\" & EthMAC & ".bat",True)
        InstallerFile.Write (Dropdown1.Value & vbCrLf & Dropdown2.Value & vbCrLf & Dropdown3.Value & vbCrLf & Dropdown4.Value)
        InstallerFile.Close
        window.close()
        End Sub
        </SCRIPT> - anonymous_128529 8 years ago
    • Hello,

      I'm not a bit HTA fan/expert anyway the script you wrote integrating the example I gave you seems ok.
      Remember that if you need to do operation on the machine like format it, distribute images etc etc you'd use the T:\ directory mapped in KBE to ''maintain the state''.
      Kind regards,
      Marco - StockTrader - StockTrader 8 years ago
Posted by: anonymous_9363 8 years ago
Red Belt
0
Isn't there a reboot between the 2 stages?!? Write the GUID to a text file and read that in the PIE. There are a quadzillion examples of how to read text files in VBS.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ