Win XP error 0x80041003 using GetObject/winmgmts

Posted by John Lewis on Server Fault See other posts from Server Fault or by John Lewis
Published on 2010-09-07T15:03:17Z Indexed on 2011/01/01 11:55 UTC
Read the original article Hit count: 388

Filed under:
|
|

My computer is called "neil" and I want to set some values using WMI in vbScript. I adapetd the script below from one supplied by Microsoft. When I run it in my browser I get

Error Type: (0x80041003) /dressage/30/pdf2.asp, line 8

I suspect it is some registry/security setting.

Any advice?

John Lewis

FULL SCRIPT

call Print_HTML_Page("http://neil/dressage/ascii.asp", "ascii")

Sub SetPDFFile(strPDFFile)
    Const HKEY_LOCAL_MACHINE = &H80000002
    strKeyPath = "SOFTWARE\Dane Prairie Systems\Win2PDF"
    strComputer = "."
    Set objReg=GetObject( _
        "winmgmts:{impersonationLevel=impersonate}!\\" & _ 
        strComputer & "\root\default:StdRegProv")
    strValueName = "PDFFileName"
    objReg.SetExpandedStringValue HKEY_LOCAL_MACHINE,_
        strKeyPath,strValueName,strPDFFile
End Sub

Sub Print_HTML_Page(strPathToPage, strPDFFile)
      SetPDFFile( strPDFFile )
      Set objIE = CreateObject("InternetExplorer.Application")
      'From http://www.tek-tips.com/viewthread.cfm?qid=1092473&page=5
      On Error Resume Next
      strPrintStatus = objIE.QueryStatusWB(6)
      If Err.Number  0 Then
            MsgBox "Cannot find a printer. Operation aborted."
            objIE.Quit
            Set objIE = Nothing
            Exit Sub
      End If

      With objIE
      .visible=0
      .left=200
      .top=200
      .height=400
      .width=400
      .menubar=0
      .toolbar=1
      .statusBar=0
      .navigate strPathToPage
      End With

      'Wait until IE has finished loading
      Do while objIE.busy
            WScript.Sleep 100
      Loop

      On Error Goto 0
      objIE.ExecWB 6,2
      'Wait until IE has finished printing
      WScript.Sleep 2000
      objIE.Quit

      Set objIE = Nothing
End Sub

© Server Fault or respective owner

Related posts about windows-xp

Related posts about wmi