views:

26

answers:

0

I'm having trouble using WMI in an ActiveX script within SQL Server Agent (2005). When I run this code inside a job, it hangs at line 6 (ConnectServer). Note: I'm using a file for logging, as SQLActiveScriptHost.Print doesn't work as advertised.

Set fso = CreateObject("Scripting.FileSystemObject")
Set txt = fso.OpenTextFile("c:\log.txt", 8, True)
Set loc = CreateObject("WbemScripting.SWbemLocator")

txt.WriteLine "BEFORE"
Set svc = loc.ConnectServer("", "root\cimv2", "", "", "", "", &H80)
txt.WriteLine "AFTER"

Set loc = Nothing
txt.Close
Set fso = Nothing

I can use this same code in a standalone VBS file on this computer (Windows Server 2003) and it runs without issues. This code is a cutdown version I was attempting to run (ExecNotificationQuery using Win32_ProcessStopTrace) against a remote machine, but this code illustrates the problem.

Looking at the documentation for SWbemLocator.ConnectServer (link text) it says that setting the iSecurityFlags parameter to 128 will make it timeout before 2 mins, but it didn't help. Any ideas, or is anyone able to reproduce?