samyukthas
07-31-2006, 01:28 AM
I have copied a small code snippet from a .vbs file to an asp page for enumerating all the connected printer names. But unfortunately i am getting an error 0x80041003 (which means current user is not authorized to execute a method). How to resolve this problem ?
Here is the code which i used..
strComputer = "hdchbscmro0821"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
Wscript.Echo "Name: " & objPrinter.Name
Wscript.Echo "Location: " & objPrinter.Location
Wscript.Echo "Default: " & objPrinter.Default
Next
I think there is some problem with WScript, how to include the APIs to make my code run ?
Any help is appreciated.
Thanks
Samyu
Here is the code which i used..
strComputer = "hdchbscmro0821"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
Wscript.Echo "Name: " & objPrinter.Name
Wscript.Echo "Location: " & objPrinter.Location
Wscript.Echo "Default: " & objPrinter.Default
Next
I think there is some problem with WScript, how to include the APIs to make my code run ?
Any help is appreciated.
Thanks
Samyu