Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. WMI call from VB6 locking HKCU

WMI call from VB6 locking HKCU

Scheduled Pinned Locked Moved Visual Basic
sysadminquestiontoolshelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dougstratton
    wrote on last edited by
    #1

    :((We have a bunch of terminal servers using roaming profiles (copies user setting to network share, includes contents of HKCU). Problem is our logon script is locking the HKCU hive and it is not unloading to be copied. I installed a tool that is now telling us this is what is locking it. wmiprvse.exe (1428) HKCU (0x1dc) Then I found out that if a certain part of our logon script does not run the profile unloads We don't really have any WMI experts here. I think we just copied this from somewhere. But what I think is going on is we are not "cleaning up" correctly after doing our calls and this is resulting in the profile being locked. This is one section that we do some calls. Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") ' determine the logon server objReg.GetStringValue HKEY_CURRENT_USER, "Volatile Environment", "logonserver", strLogonServer ' "\\" prefix needs to be removed Anyone know what we should do after this to free up the HCKU hive?

    D 1 Reply Last reply
    0
    • D dougstratton

      :((We have a bunch of terminal servers using roaming profiles (copies user setting to network share, includes contents of HKCU). Problem is our logon script is locking the HKCU hive and it is not unloading to be copied. I installed a tool that is now telling us this is what is locking it. wmiprvse.exe (1428) HKCU (0x1dc) Then I found out that if a certain part of our logon script does not run the profile unloads We don't really have any WMI experts here. I think we just copied this from somewhere. But what I think is going on is we are not "cleaning up" correctly after doing our calls and this is resulting in the profile being locked. This is one section that we do some calls. Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") ' determine the logon server objReg.GetStringValue HKEY_CURRENT_USER, "Volatile Environment", "logonserver", strLogonServer ' "\\" prefix needs to be removed Anyone know what we should do after this to free up the HCKU hive?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      There's nothing to do. Your read shouldn't be locking the key. You can TRY setting objReg to Nothing and see what that does. The WMI Standard Registry Provider doesn't have any Open/Close methods, everything like that is handled internally by the Provider. Also, if all you need is the name of the Logon Server, just grab it from the Environment strings. ExpandEnvironmentStrings Method[^]

      set WshShell = WScript.CreateObject("WScript.Shell")
      WScript.Echo "Logon Server is " & WshShell.ExpandEnvironmentStrings("%LOGONSERVER%")

      RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      D 1 Reply Last reply
      0
      • D Dave Kreskowiak

        There's nothing to do. Your read shouldn't be locking the key. You can TRY setting objReg to Nothing and see what that does. The WMI Standard Registry Provider doesn't have any Open/Close methods, everything like that is handled internally by the Provider. Also, if all you need is the name of the Logon Server, just grab it from the Environment strings. ExpandEnvironmentStrings Method[^]

        set WshShell = WScript.CreateObject("WScript.Shell")
        WScript.Echo "Logon Server is " & WshShell.ExpandEnvironmentStrings("%LOGONSERVER%")

        RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        D Offline
        D Offline
        dougstratton
        wrote on last edited by
        #3

        To bad. To set objreg to nothing is this what I would do: Set objReg= or set objReg="" or set objReg=null Thanks

        D 1 Reply Last reply
        0
        • D dougstratton

          To bad. To set objreg to nothing is this what I would do: Set objReg= or set objReg="" or set objReg=null Thanks

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Set objReg = Nothing

          Seriously, if all you need is the Logon Server, get it from the Environment strings. Only use WMI and the Registry Provider if you have to. They add a large chunk of execution weight to your script if you use them. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups