473,385 Members | 1,736 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,385 software developers and data experts.

System.Management Problem

Hi all,

Willy kindly gave me this code recently but it doesn't work when I try
to use a UNC for fileObject. Has anyone ran into this issue?

string fileObject = @"c:\\temp"; // Watch the double Backslashes
using(ManagementObject lfs = new
ManagementObject(@"Win32_LogicalFileSecuritySettin g.Path=" + "'" +
fileObject + "'"))

{do some stuff...}

Nov 16 '05 #1
4 2689
ag*******@hotmail.com wrote in
news:11**********************@f14g2000cwb.googlegr oups.com:
Hi all,

Willy kindly gave me this code recently but it doesn't work when
I try to use a UNC for fileObject. Has anyone ran into this
issue?

string fileObject = @"c:\\temp"; // Watch the double Backslashes
using(ManagementObject lfs = new
ManagementObject(@"Win32_LogicalFileSecuritySettin g.Path=" + "'"
+ fileObject + "'"))

{do some stuff...}


"c:\\temp" is not a valid UNC name. UNC names do not have a drive
identifier like "c:". Instead, they have a server name, like this:

\\server\folder\subfolder
See this for more info:

http://msdn.microsoft.com/library/de...l=/library/en-
us/off2000/html/defUNC.asp

or

http://tinyurl.com/5pofp

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 16 '05 #2
I should have been more clear. When I do use a UNC name \\blah blah
blah the Management object can't find the directory even though I have
full permission to see it.

Thanks

Nov 16 '05 #3
Looking at the code you have the @ in front of the text string for the drive
path... I would either take it out or remove the double back slash and try
it with one.
From my reading the @ infront of a string means to take it as written, if
you leave it off the single backslash is used as a leader for a format
character like /n for new line.

<ag*******@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi all,

Willy kindly gave me this code recently but it doesn't work when I try
to use a UNC for fileObject. Has anyone ran into this issue?

string fileObject = @"c:\\temp"; // Watch the double Backslashes
using(ManagementObject lfs = new
ManagementObject(@"Win32_LogicalFileSecuritySettin g.Path=" + "'" +
fileObject + "'"))

{do some stuff...}

Nov 16 '05 #4
Unfortunatelly, Path only accepts Directory or File paths not UNC paths.
Two possible options exists to solve this:
- map the path to a local drive .
- connect to the system exporting the share, and get the security descriptor
of shared directory/file path (use Win32_LogicalShareSecuritySetting
instead of Win32_LogicalFileSecuritySetting ).

Willy.

<ag*******@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi all,

Willy kindly gave me this code recently but it doesn't work when I try
to use a UNC for fileObject. Has anyone ran into this issue?

string fileObject = @"c:\\temp"; // Watch the double Backslashes
using(ManagementObject lfs = new
ManagementObject(@"Win32_LogicalFileSecuritySettin g.Path=" + "'" +
fileObject + "'"))

{do some stuff...}

Nov 16 '05 #5

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

Similar topics

0
by: Ger | last post by:
Hi, I have a problem with a Windows Service that I have created accessing System.Management.dll on a W2k3 environment. The Service runs fine on an XP machine but the same Service causes an error...
2
by: Paul Gronka | last post by:
I've got a VB.NET windows application (written in VS .NET 2003) that makes a call to WMI for retrieving the MAC Address from the client's PC. It works on 4 out of the 5 PC's tested so far. All...
1
by: theintrepidfox | last post by:
Dear Group I wonder whether anyone has some information on the cause for this error? I've created a class for Win32_BIOS with mgmtclassgen Win32_BIOS /L VB, added the file to my VB.NET project...
1
by: lcifers | last post by:
I have an application that uses the following code to return the default printer: Dim moReturn As Management.ManagementObjectCollection Dim moSearch As Management.ManagementObjectSearcher Dim...
7
by: eric | last post by:
I'm writing a program in C# and found a couple of threads about how to check the status of a printer before sending it any data, to ensure that the printer is ready to print. They say to include...
0
by: Christian Havel | last post by:
Hi, I retrieve the following calling list when a exception appears in ReleaseComObject. mscorlib.dll!System.Runtime.InteropServices.Marshal.ReleaseComObject(System.Object o = <Nicht...
1
by: ShrimpBoy | last post by:
Hi! I'm trying to erase SMS_Collection Rules using VB.NET 2003... I did that with WbemScripting, but now I need to do it with System.Management... My problem is that with System.Management...
8
by: =?Utf-8?B?YXVsZGg=?= | last post by:
i trying to collect windows services. i'm getting inconsistencies. the collection works every time locally. but remote collection yields different result depending on my lab environment. 1) in...
3
by: Marco Shaw | last post by:
I've got some C# code to create a custom PowerShell cmdlet with these statements: .... using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; .... ...
2
by: karthi84 | last post by:
Hi Experts, i have created a web application which has an option to edit the web config file from the web page. when i create an installer for this project using web setup project in VS2008 and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.