/build/static/layout/Breadcrumb_cap_w.png

How can I import registry keys using VBS?

Good morning, 

I have a vbs script to install AutoTable 2014 for AutoCAD 2014. 

The software installs with no problem at all. 

My trouble is this script is not importing the registry key.  I can log into the target machine as admin. Open a command prompt, and import the key with "regedit.exe /s [\\UNC\to\Registry\Key].reg"

The key is imported as expected. Why isn't this working when I push it with my k1000?

Additional Information:
I attach the script as a dependency to a kScript. 

The Enabled checkbox is checked.

My intended machine is selected in Deployment section. 

Run As User: Domain Admin

Allow Run While Logged Off checkbox is checked. 

Verify:
    Always Fail
Remediation:
    Launch "C:\Windows\System32\cscript.exe" with params "$KACE_DEPENDENCY_DIR)\Install_AutoTable_for_ACAD_2014.vbs"


  1. ' Bullet Catcher
  2. ' Install_AutoTable_for_ACAD_2014.vbs
  3. ' this script is designed to install AutoTable for AutoCAD 2014. The script then applies licensing as needed.
  4. ' this script will install both AutoTable for ACAD 2014 as well as AutoTable for ACAD LT 2014
  5.  
  6.  
  7. ' ***** Variable Dictionary *****
  8. ' objFSO                = used to determine if certain files exist on the host machine.
  9. ' objNetwork            = gets computer name of current host machine.
  10. ' objShell              = Windows shell object used to install the AutoTable 2014 executable file.
  11. ' execute_command       = command line to carry out a specified command
  12. ' computer_name         = Name of the host computer. Used to determine what license to apply to the AutoTable installation
  13. ' install_file          = Command line for the AutoTable executable file.
  14. ' reg_file              = The registry key to be imported that contains the licensing information.
  15.  
  16.  
  17.  
  18. set objFSO = CreateObject("Scripting.FileSystemObject")
  19. set objNetwork = WScript.CreateObject("WScript.Network")
  20. Set objShell = WScript.CreateObject ("WSCript.Shell")
  21.  
  22.  
  23. execute_command = "cmd /c "
  24. computer_name = objNetwork.ComputerName
  25.  
  26. ' Command line to install AutoTable 2014.
  27. install_file = """[UNC to]\AutoTable54-for-AutoCAD2014-x64.exe ""/VERYSILENT /NORESTART /LOG /SUPPRESSMSGBOXES"
  28.  
  29.  
  30. ' Verify ACAD 2014 or ACAD LT 2014 is installed by looking for the respective .exe
  31. if objFSO.FileExists ("C:\Program Files\Autodesk\AutoCAD 2014\acad.exe"Or objFSO.FileExists ("C:\Program Files\Autodesk\AutoCAD LT 2014\acadlt.exe")Then
  32.         ' Determine license to apply based on computer name.
  33.         Select Case computer_name
  34.                 case "LIST 1""OF""COMPUTER""NAMES"
  35.                         reg_file = """[UNC to]\AutoTable_for_ACAD_2014_License_41_seats.reg"""
  36.                        
  37.                 case "LIST 2""OF""COMPUTER""NAMES"
  38.                         reg_file = """[UNC to]\AutoTable_for_ACAD_2014_License_5_seats.reg"""
  39.                        
  40.                 case "LIST 3""OF""COMPUTER""NAMES"
  41.                         reg_file = """[UNC to]\AutoTable_for_ACAD_2014_License_3_seats.reg"""
  42.                        
  43.                 case "LIST 4""OF""COMPUTER""NAMES"
  44.                         reg_file = """[UNC to]\AutoTable_for_ACAD_2014_License_1_seat.reg"""
  45.                        
  46.                 case "LIST 5""OF""COMPUTER""NAMES"
  47.                
  48.                         ' Change the install_file to install AutoTable for AutoCAD LT 2014
  49.                         install_file = """[UNC to]AutoTable53-for-AutoCADLT2014-x64.exe ""/VERYSILENT /NORESTART /LOG"
  50.                         reg_file = """[UNC to]\AutoTable_for_ACAD_LT_2014_License_5_seats.reg"""
  51.         End Select
  52. End if
  53.  
  54. ' After determining proper license information, verify AutoTable is not already installed.
  55. if objFSO.FileExists ("C:\Program Files\Cadig\AutoTable\2014\WhatsNew.txt"then
  56.         'wscript.echo "AutoTable 2014 INSTALLED."
  57. else
  58.         ' if not installed, install AutoTable 2014
  59.         'wscript.echo "AutoTable 2014 not installed."
  60.         objShell.Run execute_command & install_file, 0, TRUE
  61. end if
  62.  
  63. ' Import the appropriate registry keys to apply licensing
  64. objShell.Run execute_command & "regedit.exe /s " & reg_file, 0, True

1 Comment   [ + ] Show comment
  • My take would that be that the KBox agent executes scripts with the local System account. As you know, this account has no access to the network. Thus, calls to UNCs are ignored.

    If the script executioin is set to execute in the logged-in user's context, then it's likely (hopeful, even, given where it's trying to write!) that the user has no write access to HKLM.

    Of course, if your script had logging, you'd see all of this information. Seek out and use the rather excellent clsLog.VBS which makes adding logging to VBS a no-brainer.

    EDIT:
    Here...I saved you the trouble: http://www.visualbasicscript.com/m24797-print.aspx - anonymous_9363 9 years ago
    • Thanks for this. I will have to look more into how to use that logger. I am running the kScript as an admin user. There shouldn't be any trouble there. - anonymous_95342 9 years ago

Answers (1)

Posted by: SMal.tmcc 9 years ago
Red Belt
2
the kace client is 32 bit so the script is running in 32 bit mode.  so when you try the merge the registry it is probaly working just the keys are going to HKLM\software\wow6432node\...etc not HKLM\software\...etc like you expect.  check under there and if they are there change your reg merge file lines to hklm64 instead of hklm
HKLM\software\wow6432node\...etc

Comments:
  • There are no AutoTable 2014 keys at HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Cadig

    When I import the keys locally they are imported as expected to HKEY_LOCAL_MACHINE\SOFTWARE\Cadig\Cadig2014\AutoTable - anonymous_95342 9 years ago
    • that means the sysnative redirection was not the problem then

      here is a variation on the way to do this in vbs, they add the other characters, and that may matter & Chr(34)
      http://myitforum.com/cs2/blogs/dhite/archive/2006/09/01/Using-Vbs-To-Silently-Import-Reg-Files.aspx
      http://social.technet.microsoft.com/Forums/en-US/033ac3b9-c6c7-46fd-b0b6-decd8ad497fa/vbscript-import-registry-file - SMal.tmcc 9 years ago
      • Thanks for the info. But I was still not successful.
        I have the script pushed through kBox, AutoTable installs but the reg key wont import. I can manually run the vbs file and it all works as expected.

        Im having a hard time understanding how the kBox does it differently? - anonymous_95342 9 years ago
 
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