The Glimmerman Posted October 29, 2005 Share Posted October 29, 2005 Hi all.I've made a script that installs a TCP/IP port. Then installs the printer that uses that port. Adding the TCP/IP port works like a charm, but installing the printer not.I've searched the net and my script should work. But it doesn't The port is created before installing the printer.I get this error message : Line: 66Char: 2Error: Generic Failure Code: 80041001 Source: SWbemObjectExI hope that someone knows the answer.strComputer = "." Set WshShell = WScript.CreateObject("WScript.Shell") Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")'Install TCP/IP Port :Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_ objNewPort.Name = "IP_192.168.0.5" objNewPort.Protocol = 2 objNewPort.HostAddress = "192.168.0.5" objNewPort.PortNumber = "515" objNewPort.Queue = "LPT1_PASSTHRU" objNewPort.SNMPCommunity = "public" objNewPort.SNMPEnabled = False objNewPort.Put_'Stop Spooler Service Set colServiceList = objWMIService.ExecQuery _ ("Select * from Win32_Service where Name='Spooler'") For Each objService In colServiceList errReturn = objService.StopService() WScript.Sleep 5000 Next'Start Spooler Service For Each objService In colServiceList errReturn = objService.StartService() WScript.Sleep 5000 Next'Install Driver :'' objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True' ' Set objDriver = objWMIService.Get("Win32_PrinterDriver")'' objDriver.Name = "hp deskjet 990c"' objDriver.SupportedPlatform = "Windows NT x86"' objDriver.Version = "3"' objDriverPath = "C:\WINNT\System32\Printui.dll"' objInfname = "C:\WINNT\inf\ntprint.inf"' intResult = objDriver.AddPrinterDriver(objDriver)' 'Install TCP-Printer : strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ objPrinter.DriverName = "hp deskjet 990c" objPrinter.PortName = "IP_192.168.0.5" objPrinter.DeviceID = "HP DeskJet 990CXi" objPrinter.Network = True objPrinter.Shared = False objPrinter.ShareName = "" objPrinter.Published = False objPrinter.Location = "@ LAN" objPrinter.Put_Wscript.Quit Link to comment Share on other sites More sharing options...
cluberti Posted October 30, 2005 Share Posted October 30, 2005 That's a pretty generic error, but it usually points to a permissions or firewall problem. Since I'm assuming it's not a firewall problem, have you checked to make sure that the spooler service really did restart? What about the RPC services - are they all running? Link to comment Share on other sites More sharing options...
IcemanND Posted October 31, 2005 Share Posted October 31, 2005 I ran your script on my machine and had no problems at all. Even when some or all of he components were already installed I rcvd no errors. I'd look at permission problems like cluberti suggested. Link to comment Share on other sites More sharing options...
The Glimmerman Posted October 31, 2005 Author Share Posted October 31, 2005 OK then.I will check the RPC services.Thank god my script is ok **** my pc isn't working Thx all. Link to comment Share on other sites More sharing options...
The Glimmerman Posted November 1, 2005 Author Share Posted November 1, 2005 That didn't work.Strange mmmm..I will keep tryingIf someone knows an other method of installing printers unattended.Please let me know.@ IcemanND and clubertiThanks for the quick reply and suggestions. Link to comment Share on other sites More sharing options...
druiddk Posted December 5, 2005 Share Posted December 5, 2005 Please could you point out the things that are needed to be changed for this to work?I looked into it abit and figured out some of them, but I'm abit unsure... does the drivers need to be installed before running this script?Are these general Windows files or driver files?' objDriverPath = "C:\WINNT\System32\Printui.dll"' objInfname = "C:\WINNT\inf\ntprint.inf" Link to comment Share on other sites More sharing options...
cluberti Posted December 5, 2005 Share Posted December 5, 2005 If you can get the printer installed on another machine, you can use the printmig tool to move the printer and the ports over to any number of other machines. I know it isn't as pretty as a vbscript, but it does work . Link to comment Share on other sites More sharing options...
druiddk Posted December 7, 2005 Share Posted December 7, 2005 (edited) @cluberti:Microsoft printmig.exe RULES!Beware there is a commercial product that does about the same with the same name... dont buy that! Just use the Microsoft tool thats free - its works perfectly! Edited December 7, 2005 by druiddk Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now