Re: Using WMI from Within a service.



guillaume.gerard@xxxxxxxxx wrote:
Dear Gerry,

Thank you for your answer. Let me clarify the operations I performed.

I have got a srvany.exe service that starts a vbscript. This vbscript
performes the following operations :

-------------------------------------------------------------------------
err.clear
Set objWMIService = GetObject("winmgmts:")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "IP_" & printer_ip
objNewPort.Protocol = 1
objNewPort.HostAddress = printer_ip
objNewPort.PortNumber = printer_port
objNewPort.SNMPEnabled = True
objNewPort.SNMPCommunity = "public"
objNewPort.Put_
if err.number<>0 then
LogtoFile "Errors detected during printer port installation - return
code = "&err.number
Erreur
end if
-------------------------------------------------------------------------

The objNewPort.Put_ method returns the following error: 0x80041003 =
Acces Denied.

When I run the script within a user session, it works well.

Please, tell me if you require further information.

Gerry Hickman a écrit :

guillaume.gerard@xxxxxxxxx wrote:

When the script is executed using a local account, without the srvany
service, everything goes right.
You mean you can set up a printer on a remote server using a local account?

What ever the answer is, you need to be more specific about exactly what
you are doing with this printer queue (or printer connection, or driver
installation). The access level required will depend on what you are
actually doing...

--
Gerry Hickman (London UK)


I'm experiencing a similar problem. During development I run my Windows Service (C# .net 1.1) application on the console as a normal User account. I'm able to create WMI event queries on remote servers without any problems.

But when I install the application as a Service (LOCAL SYSTEM) the attempts to make event queries fail with mysterious 'Invalid Parameter' error.

I was under the impression that LOCAL SYSTEM has privileges similar to a local Administrator, and definitely has more privileges than my normal User development account (not even Power User.)

My dev machine is win2000 and I'm connecting to 2000, XP and Server 2003 systems.

Any advice greatly appreciated.

Colin
.



Relevant Pages

  • Re: Using WMI from Within a service.
    ... I have got a srvany.exe service that starts a vbscript. ... But when I install the application as a Service (LOCAL SYSTEM) the ... User development account ... enough rights on your PC, for wmi, and not remote machines. ...
    (microsoft.public.win32.programmer.wmi)
  • Re: VBscript not working after SP4 W2KPro
    ... Peter Williams wrote: ... I have a vbscript the will not run as normal user but runs as ... > administrator after I updated the system to SP4. ...
    (microsoft.public.scripting.vbscript)

Loading