473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Setting file persmissions with WMI using a UNC path

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
Nov 20 '05 #1
1 3973
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.

Johan wrote:
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

--
Gerry Hickman (London UK)
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: G. Richard Bellamy | last post by:
I'm trying to unset the Encrypted attribute on all the files in a path. The attribute is not getting set. What am I doing wrong? Perhaps there's another newsgroup I can send this to? Here's...
7
by: John R. | last post by:
How do you set the following file attributes: Compressed Encrypted Normal ReparsePoint SparsePoint You CAN'T set these using FileInfo.Attributes or File.SetAttributes. It doesn't work for...
3
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There...
1
by: phil campaigne | last post by:
On Mon, 1 Mar 2004, phil campaigne wrote: >> Nigel J. Andrews wrote: >> > > >>> >On Mon, 1 Mar 2004, Phil Campaigne wrote: >>> > >>> >
2
by: Sam | last post by:
Hi all I'm looking for a way to detect the background color of my internal webpage through a stylesheet. And so far, the only solution I find is to open the styles.css file and parse the...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
24
by: dancer | last post by:
Using ASP.net 1.1 and Microsoft Access. I received the following error message. Why? I have closed the Access file. I have another very small access file that opens with no trouble with the...
2
by: Steven Spits | last post by:
Hi group, I need to write a file in a network share automatically from within the browser. I realise this is an uncommon scenario that would need some work on the client side. The less the...
4
by: nokia33948 | last post by:
Hi there, I am writing a VB.NET 2005 application that connects to an MySQL DB (it could be MS SQL, one day...). One of the window forms contains a gridview with some rows coming from a table on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.