Results 1 to 5 of 5

Thread: Script to change the local printer port - error 80041001

  1. #1
    Pedro Lima Guest

    Script to change the local printer port - error 80041001

    Dear Friends,

    We will rename a lot of client machines here in the network - all of them
    are running Windows XP with SP2. The problem behind this fact is obvious:
    many workstations using local ports that are not really "local" will face
    discontinued printing services. I have made a script - based on others found
    in the internet - that try to change the port. The problem is that it doesn't
    work. The error is a generic failure in SWbemObjectEx (80041001) in line 9.
    Here is the code:

    Line 1: strComputer = "."
    Line 2: Set objWMIService = GetObject("winmgmts:\\" & strComputer &
    "\root\CIMV2")
    Line 3:
    Line 4: Set colPrinters = objWMIService.ExecQuery ("Select * from
    Win32_Printer")
    Line 5:
    Line 6: For Each objPrinter in colPrinters
    Line 7: If objPrinter.PortName = "\\sieci_sso01\BrotherH" Then
    Line 8: objPrinter.PortName = "\\stici_sso01\BrotherH"
    Line 9: objPrinter.Put_
    Line10: End If
    Line11: Next

    Well... Does anybody have a solution for this ? This scenario is easily
    reproducible in any environment, so you can see the error in your machine to
    try to figure out why it happens.

    --
    Pedro Lima

  2. #2
    Alan Morris [MSFT] Guest

    Re: Script to change the local printer port - error 80041001

    How are you creating the new Local Port?

    "\\stici_sso01\BrotherH"

    if you do not add the port, it cannot be set

    prncnfg -t -p PRINTER -r "\\newserver\oldshare"
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

    Unable to configure printer PRINTER Error 0x80041001 Generic failure
    Operation PutInstance
    Provider Win32 Provider
    Description The specified port is unknown.
    Win32 error code 1796

    --
    Alan Morris
    Windows Printing Team
    Search the Microsoft Knowledge Base here:
    http://support.microsoft.com/search/?adv=1

    This posting is provided "AS IS" with no warranties, and confers no rights.

    "Pedro Lima" <PedroLima@discussions.microsoft.com> wrote in message
    news:22F5C2BC-5A3B-4F37-B753-149AC122AEE9@microsoft.com...
    > Dear Friends,
    >
    > We will rename a lot of client machines here in the network - all of them
    > are running Windows XP with SP2. The problem behind this fact is obvious:
    > many workstations using local ports that are not really "local" will face
    > discontinued printing services. I have made a script - based on others
    > found
    > in the internet - that try to change the port. The problem is that it
    > doesn't
    > work. The error is a generic failure in SWbemObjectEx (80041001) in line
    > 9.
    > Here is the code:
    >
    > Line 1: strComputer = "."
    > Line 2: Set objWMIService = GetObject("winmgmts:\\" & strComputer &
    > "\root\CIMV2")
    > Line 3:
    > Line 4: Set colPrinters = objWMIService.ExecQuery ("Select * from
    > Win32_Printer")
    > Line 5:
    > Line 6: For Each objPrinter in colPrinters
    > Line 7: If objPrinter.PortName = "\\sieci_sso01\BrotherH" Then
    > Line 8: objPrinter.PortName = "\\stici_sso01\BrotherH"
    > Line 9: objPrinter.Put_
    > Line10: End If
    > Line11: Next
    >
    > Well... Does anybody have a solution for this ? This scenario is easily
    > reproducible in any environment, so you can see the error in your machine
    > to
    > try to figure out why it happens.
    >
    > --
    > Pedro Lima




  3. #3
    Pedro Lima Guest

    Re: Script to change the local printer port - error 80041001

    Alan,

    Thank you for your answer to my post. I have just one more question: how can
    I add a local port first ? I have seen examples on how to do it, but only on
    IP ports. I have not seen redirection ports - like my case. I have tried the
    command you showed in your last post, but it didn't work out. My version of
    prncfg is the one that comes with Windows 2003 resource kit that is available
    for download in microsoft web page.

    Greatings,
    --
    Pedro Lima


    "Alan Morris [MSFT]" wrote:

    > How are you creating the new Local Port?
    >
    > "\\stici_sso01\BrotherH"
    >
    > if you do not add the port, it cannot be set
    >
    > prncnfg -t -p PRINTER -r "\\newserver\oldshare"
    > Microsoft (R) Windows Script Host Version 5.6
    > Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
    >
    > Unable to configure printer PRINTER Error 0x80041001 Generic failure
    > Operation PutInstance
    > Provider Win32 Provider
    > Description The specified port is unknown.
    > Win32 error code 1796
    >
    > --
    > Alan Morris
    > Windows Printing Team
    > Search the Microsoft Knowledge Base here:
    > http://support.microsoft.com/search/?adv=1
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    > "Pedro Lima" <PedroLima@discussions.microsoft.com> wrote in message
    > news:22F5C2BC-5A3B-4F37-B753-149AC122AEE9@microsoft.com...
    > > Dear Friends,
    > >
    > > We will rename a lot of client machines here in the network - all of them
    > > are running Windows XP with SP2. The problem behind this fact is obvious:
    > > many workstations using local ports that are not really "local" will face
    > > discontinued printing services. I have made a script - based on others
    > > found
    > > in the internet - that try to change the port. The problem is that it
    > > doesn't
    > > work. The error is a generic failure in SWbemObjectEx (80041001) in line
    > > 9.
    > > Here is the code:
    > >
    > > Line 1: strComputer = "."
    > > Line 2: Set objWMIService = GetObject("winmgmts:\\" & strComputer &
    > > "\root\CIMV2")
    > > Line 3:
    > > Line 4: Set colPrinters = objWMIService.ExecQuery ("Select * from
    > > Win32_Printer")
    > > Line 5:
    > > Line 6: For Each objPrinter in colPrinters
    > > Line 7: If objPrinter.PortName = "\\sieci_sso01\BrotherH" Then
    > > Line 8: objPrinter.PortName = "\\stici_sso01\BrotherH"
    > > Line 9: objPrinter.Put_
    > > Line10: End If
    > > Line11: Next
    > >
    > > Well... Does anybody have a solution for this ? This scenario is easily
    > > reproducible in any environment, so you can see the error in your machine
    > > to
    > > try to figure out why it happens.
    > >
    > > --
    > > Pedro Lima

    >
    >
    >


  4. #4
    Pedro Lima Guest

    Re: Script to change the local printer port - error 80041001

    Guys... Mr. Alan (thanks Alan) gave me part of the solution. He pointed to me
    that I had to create the port first. Then, God gave me a light to find the
    rest of the solution to my problem. Since there is not an easy way to create
    a port, I decided to create it directly in the registry. I share with you the
    script that is working! Yes!!!

    strkey = "Software\Microsoft\Windows NT\CurrentVersion\Ports"
    strType = "REG_SZ"
    strComputer = "."
    set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")

    Set colPrinters = objWMIService.ExecQuery ("Select * from Win32_Printer")
    For Each objPrinter in colPrinters
    If objPrinter.PortName = "\\sieci_sso01\BrotherH" Then
    strValue = "\\stici_sso01\BrotherH"
    call createport(strkey, strvalue, strtype)
    objPrinter.PortName = strValue
    objPrinter.Put_
    End If
    Next

    Function createport(key, value, type)
    Set objService = objWMIService.ExecQuery ("Select * from Win32_Service
    Where Name = 'Spooler'")
    For Each objService in ObjService
    objService.StopService()
    const HKEY_LOCAL_MACHINE=&H80000002
    set regkey=GetObject("winmgmts:root\default:StdRegProv")
    createkey=regkey.setstringvalue(HKEY_LOCAL_MACHINE,Key,Value,"")
    set regkey=nothing
    objService.StartService()
    Next
    End Function

    --
    Pedro Lima


  5. #5
    lorenzo Guest

    RE: Script to change the local printer port - error 80041001



    "Pedro Lima" wrote:

    > Dear Friends,
    >
    > We will rename a lot of client machines here in the network - all of them
    > are running Windows XP with SP2. The problem behind this fact is obvious:
    > many workstations using local ports that are not really "local" will face
    > discontinued printing services. I have made a script - based on others found
    > in the internet - that try to change the port. The problem is that it doesn't
    > work. The error is a generic failure in SWbemObjectEx (80041001) in line 9.
    > Here is the code:
    >
    > Line 1: strComputer = "."
    > Line 2: Set objWMIService = GetObject("winmgmts:\\" & strComputer &
    > "\root\CIMV2")
    > Line 3:
    > Line 4: Set colPrinters = objWMIService.ExecQuery ("Select * from
    > Win32_Printer")
    > Line 5:
    > Line 6: For Each objPrinter in colPrinters
    > Line 7: If objPrinter.PortName = "\\sieci_sso01\BrotherH" Then
    > Line 8: objPrinter.PortName = "\\stici_sso01\BrotherH"
    > Line 9: objPrinter.Put_
    > Line10: End If
    > Line11: Next
    >
    > Well... Does anybody have a solution for this ? This scenario is easily
    > reproducible in any environment, so you can see the error in your machine to
    > try to figure out why it happens.
    >
    > --
    > Pedro Lima


Similar Threads

  1. Serial Port in Use or -192 Error for USB printer
    By Y2kCyK in forum Operating Systems
    Replies: 3
    Last Post: 14-10-2009, 09:50 PM
  2. Local Admin Password change script for Domain PC's
    By Dharitree in forum Window 2000 Help
    Replies: 3
    Last Post: 13-10-2008, 09:32 AM
  3. error 0x000003eb when trying to install a local printer
    By pdmellon@gmail.com in forum Vista Help
    Replies: 3
    Last Post: 07-05-2008, 08:24 AM
  4. Replies: 3
    Last Post: 22-04-2007, 02:10 AM
  5. Missing port types : local port and Standard TCP/IP port
    By NIcaBoy in forum Windows XP Support
    Replies: 3
    Last Post: 28-12-2006, 07:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,997,210.90250 seconds with 17 queries