Reputation: 59
We have an application that we have instrumented with WMI, and have added a WMI method which is a ManagementTask
. When we try to invoke this management task from another application the method is getting called just fine, however within that thread of execution we are trying to write to a file, send a command to the SCM, and perform debug logging. None of these three items will execute because they seem to be running into permissions problems.
When we try to write to a file we get the error
Either a required impersonation level was not provided, or the provided impersonation level is invalid.
How do we resolve this?
Upvotes: 0
Views: 277
Reputation: 1470
Al, I feel your pain. Any attempt to write to a file using native WMI methods will fail since WMI is not capable of doing it. However, there is a workaround created by Frank White using C#, which was fleshed out in VBS. Here's the line he created that does the magic:
InputParameters("CommandLine") = "cmd /c echo myFTPCommands > c:\ftpscript.txt"
Please refer to the VBS method for full description, and post back here if you have questions about it. And yes, you will need to set impersonationLevel, as shown in the VBS page.
For sending a command to the SCM, that shouldn't be a problem, so try it separately to ensure there's no issues. For debug logging, if you're writing a file to the remote system, then you'll have to use the workaround mentioned above.
Upvotes: 0