Setting file persmissions with WMI using a UNC path

J

Johan

Hi all

I'm trying to set the permissions of a file using WMI, and since i'm
writing a windows service i want to use UNC paths doing this because
the destination might not be a mapped path. I'we been looking around
here at google and gotten the impression that it is not possible to
use UNC paths when working with WMI, is that really so? Or does anyone
know how how to set file permissions using a UNC path? I'we gotten to
work ok with a mapped path to a file on another computer, but if I
feed the same code with a UNC path instead i get a error back saying
"Not Found". Here is the code that works with a mapped path.
Note that this i VB.NET and only a part of the code.

The reason for using WMI instead of ADSI is that I want this to work
in a Novell enviorment as well, and I imagine that WMI can manage
that.

Dim FolderPath as string = Any mapped path
Dim objFile As New ManagementObject(New
ManagementPath("Win32_LogicalfileSecuritySetting='" + _
FolderPath.Replace("\", "\\") + "'"))
Dim options As New InvokeMethodOptions(Nothing, New TimeSpan(0, 0, 0,
5))
Dim outparams As ManagementBaseObject =
objFile.InvokeMethod("GetSecurityDescriptor", Nothing, options)

Console.Write(objFile.GetText(TextFormat.Mof))


Another solution to my problem would be to do a temporary mapping the
the UNC path from withing my service. But if I do that it seams that
WMI does not get my temporary mapping. Can I make WMI to somehow
"reinit" itself so it gets the mapping i've made from the code.

Thanks
Johan
 
G

Gerry Hickman

Hi,

As far as I know, WMI can only work with "local" files, however "local"
can mean on a different box because you can connect to WMI on a
different box.

It's a pain if you want to create a process whos image (exe file)
resides on a different computer. Some 3rd party vendors take the
approach of copying the whole file to every remote computer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top