Go Back   TechArena Community > Technical Support > Computer Help > Windows XP > Windows XP Support
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Script to change the local printer port - error 80041001

Windows XP Support


Reply
 
Thread Tools Search this Thread
  #1  
Old 20-02-2008
Pedro Lima
 
Posts: n/a
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

Reply With Quote
  #2  
Old 20-02-2008
Alan Morris [MSFT]
 
Posts: n/a
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



Reply With Quote
  #3  
Old 20-02-2008
Pedro Lima
 
Posts: n/a
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

>
>
>

Reply With Quote
  #4  
Old 20-02-2008
Pedro Lima
 
Posts: n/a
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

Reply With Quote
  #5  
Old 22-02-2008
lorenzo
 
Posts: n/a
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

Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows XP > Windows XP Support
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Script to change the local printer port - error 80041001"
Thread Thread Starter Forum Replies Last Post
Serial Port in Use or -192 Error for USB printer Y2kCyK Operating Systems 3 14-10-2009 09:50 PM
Local Admin Password change script for Domain PC's Dharitree Window 2000 Help 3 13-10-2008 09:32 AM
error 0x000003eb when trying to install a local printer pdmellon@gmail.com Vista Help 3 07-05-2008 08:24 AM
Change local administrator password ? through GPO or push script ? Imthyaz K Active Directory 3 22-04-2007 02:10 AM
Missing port types : local port and Standard TCP/IP port NIcaBoy Windows XP Support 3 28-12-2006 07:38 PM


All times are GMT +5.5. The time now is 07:59 PM.