mapping a printer vb script (premission denied) - TechRepublic
Question
April 4, 2007 at 06:56 AM
m-6rom

mapping a printer vb script (premission denied)

by m-6rom . Updated 19 years, 1 month ago

hi,
I have 30 printers in my company,
If I try to connect winxp share printer it’s work fine, bat if I try to connect a win98 share printer I get “premission denied”

this is the script:

strcomputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)

Set colInstalledPrinters = objWMIService.ExecQuery _
(“Select * from Win32_Printer”)

For Each objPrinter in colInstalledPrinters
If “\\” = Left( objPrinter.ServerName, 2 ) Then
objPrinter.Delete_
Else
end if
next

Set WSHNetwork = CreateObject(“WScript.Network”)

‘List of printers to connect
WSHNetwork.AddWindowsPrinterConnection “\\10.20.0.118\hp”
WshNetwork.SetDefaultPrinter “\\10.20.0.118\hp”

This discussion is locked

All Comments