Question Locked

mapping a printer vb script (premission denied)

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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"

2 replies

by cyrusrynlee

- Try to install the latest version of wsh/vbscript on your win98 workstation.

- Many WMI commands don't work/are not supported in win98 versions. Check WMI classes library if the object you're trying to use can be run on win98 OS.

- in a domain setup, you must be the administrator of that domain (or try to add yourself in the local admin group). In a workgroup setup, you need to add/create yourself as a local administrator on each of the clients participating in the workgroup.

- Permission denied messages usually means you dont have access to that resource. Your script needs to have administrator access to execute its instructions properly.

This discussion is closed to new replies.