rameshsamala
asked on
Retrive shared folders from vb code
hi, I have to find out shared folder from local system and i need to change the permissions from vb code please help me any one
Thank you.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yeah, I just did a "cut-and-paste" from one of my programs... so it's not a complete solution. That also means that it contains a lot of stuff that doesn't really pertain to the context of the example.
For example, ds is a DataSet and ID is a string... Neither are required in the context of this example, so I'd recommend that you just comment out all of the database-related sections of the example. Or change all of the database assignments into debug.writeline statements. Something like:
Before:
dr = ds.Tables("Permissions").N ewRow()
dr("ID_Perm") = ID
dr("Perm_ID") = perm_cnt
dr("Perm_Target") = share
After:
'dr = ds.Tables("Permissions").N ewRow()
'dr("ID_Perm") = ID
debug.writeline("Perm_ID: " & perm_cnt)
debug.writeline("Perm_Targ et: " & share)
For example, ds is a DataSet and ID is a string... Neither are required in the context of this example, so I'd recommend that you just comment out all of the database-related sections of the example. Or change all of the database assignments into debug.writeline statements. Something like:
Before:
dr = ds.Tables("Permissions").N
dr("ID_Perm") = ID
dr("Perm_ID") = perm_cnt
dr("Perm_Target") = share
After:
'dr = ds.Tables("Permissions").N
'dr("ID_Perm") = ID
debug.writeline("Perm_ID: " & perm_cnt)
debug.writeline("Perm_Targ
Thank graye.
To get it working I also needed to insert the following definitions:
Dim wmi As ManagementClass
Dim objs As ManagementObjectCollection
Dim obj As ManagementObject
Dim MgmtPath As String
Dim RemotePC As String
Also I removed everything related to
' AppSettings' and 'gui'.
That works for the local environment.
But if I want to access mapped shares I get during execution of the following code
RemotePC = "myremotecomputername"
MgmtPath = "\\" & RemotePC & "\root\cimv2:"
wmi = New ManagementClass(MgmtPath & "Win32_Share")
objs = wmi.GetInstances() ' <== message "System.UnAuthorizedAccesE xception" occurs
I'm having mapped some shares from myremotecomputername on mylocacomputer
using user/password where user/password does not exist on the local computer.
It there a way to enumerate these mapped shares too?
HStrix
To get it working I also needed to insert the following definitions:
Dim wmi As ManagementClass
Dim objs As ManagementObjectCollection
Dim obj As ManagementObject
Dim MgmtPath As String
Dim RemotePC As String
Also I removed everything related to
' AppSettings' and 'gui'.
That works for the local environment.
But if I want to access mapped shares I get during execution of the following code
RemotePC = "myremotecomputername"
MgmtPath = "\\" & RemotePC & "\root\cimv2:"
wmi = New ManagementClass(MgmtPath & "Win32_Share")
objs = wmi.GetInstances() ' <== message "System.UnAuthorizedAccesE
I'm having mapped some shares from myremotecomputername on mylocacomputer
using user/password where user/password does not exist on the local computer.
It there a way to enumerate these mapped shares too?
HStrix
Sorry, that was not my target.
I thought it should be discussed if they're any outstandings.
HStrix
I thought it should be discussed if they're any outstandings.
HStrix
This doesn't work correctly on Windows 2000 clients. I was getting an math overflow. I changed to INT64.
Public Shared Function DirectoryMaskToString(ByVa l mask As Int64) As String
Also, some NTFS permissions are not resolved in the ENUM on Win2k. Share permissions are fine.
This should be LIST or READ?
<Path>C:\Program Files</Path>
<DACLType>NTFS</DACLType>
<Account>BUILTIN\Users</Ac count>
<Type>Allow</Type>
<Permission>Special (0xA0000000):</Permission>
And this should be LIST or READ?
<Path>C:\Program Files</Path>
<DACLType>NTFS</DACLType>
<Account>BUILTIN\Users</Ac count>
<Type>Allow</Type>
<Permission>Special (0x100000):</Permission>
Read & Execute is picked up.
<Path>C:\Program Files</Path>
<DACLType>NTFS</DACLType>
<Account>BUILTIN\Users</Ac count>
<Type>Allow</Type>
<Permission>Read & Execute</Permission>
Public Shared Function DirectoryMaskToString(ByVa
Also, some NTFS permissions are not resolved in the ENUM on Win2k. Share permissions are fine.
This should be LIST or READ?
<Path>C:\Program Files</Path>
<DACLType>NTFS</DACLType>
<Account>BUILTIN\Users</Ac
<Type>Allow</Type>
<Permission>Special (0xA0000000):</Permission>
And this should be LIST or READ?
<Path>C:\Program Files</Path>
<DACLType>NTFS</DACLType>
<Account>BUILTIN\Users</Ac
<Type>Allow</Type>
<Permission>Special (0x100000):</Permission>
Read & Execute is picked up.
<Path>C:\Program Files</Path>
<DACLType>NTFS</DACLType>
<Account>BUILTIN\Users</Ac
<Type>Allow</Type>
<Permission>Read & Execute</Permission>
I tried to use your code
but I get some compilation errors.
"ds" and "ID" are not defined.
Can you help me out?
Thank you.
HStrix