开发者

vbscript for creating registry entries was working, now it isn't. Any ideas?

开发者 https://www.devze.com 2023-03-11 05:00 出处:网络
I have a vbscript that creates a registry entry on a Windows Server 2003 machine. This script has been working fine for about a year now, but recently it just st开发者_如何学Pythonopped working. I am

I have a vbscript that creates a registry entry on a Windows Server 2003 machine. This script has been working fine for about a year now, but recently it just st开发者_如何学Pythonopped working. I am thinking that a windows update must have changed something, maybe a security setting, whereby this script is no longer permitted to execute. The script uses the following function to create an entry in HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ for new ODBC connections:

Function CreateRegKey (sComputer, hTree, sKey)
  Dim oRegistry
  Dim lResult   
  Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}//" & sComputer & "/root/default:StdRegProv")
  lResult = oRegistry.CreateKey(hTree, sKey)
  If (lResult = 0) And (Err.Number = 0) Then
     CreateRegKey = 0
  Else
     CreateRegKey = 1
     msgbox("Create Key " & sKey & " Failed")
  End If
  Set oRegistry = Nothing
End Function

This function is called as follows:

Const HKEY_LOCAL_MACHINE    = &H80000002
sPath = "SOFTWARE\ODBC\ODBC.INI\" & DataSourceName 
'Create ODBC entry
If (0 = CreateRegKey(sComputer, HKEY_LOCAL_MACHINE, sPath)) Then
  ....
Else    
  ....
End If

Does anyone know of a windows update that could have caused this script to suddenly stop working? The script stops on the following line:

lResult = oRegistry.CreateKey(hTree, sKey)

It does not give an error or anything. It just stops on that line.

Anyone got an idea what is going wrong here and how I could fix it? Thanks.

EDIT: I now get the error number returned by CreateKey. It returns the following:

Err.Number: -2147023533

Err.Description: Cannot start a new logon session with an ID that is already in use

Does anyone know what is causing this and how to work around it? Thanks.


The description for the error code -2147023533 (0x80070553) is:

Cannot start a new logon session with an ID that is already in use.

A search for this code and description reveals:

  • hotfix KB2283089 for fixing the error,
  • an assumption that the error is caused by KB979683,
  • a suggestion to reinstall service packs in order to fix the error.

Give these a try and see if it helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消