Solved

VB6: get the comment info for a given computer and share

Posted on 2006-07-14
12
280 Views
Last Modified: 2008-03-03
Hello experts,
in my Visual Basic (VB6) program I need for a given computername and sharename
getting the comment related to that sharename.
   \\mycomputer\myshare\...
I don't need to enumerate the network.

If anyone can help me,
please supply appropriate information.

Thank you for any help.

   HStrix
 
0
Comment
Question by:HStrix
  • 7
  • 5
12 Comments
 
LVL 41

Accepted Solution

by:
graye earned 200 total points
ID: 17110753
I'd consider using Windows Management Instrumentation (WMI)... http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_share.asp

 Here is an example to demonstrate the concepts

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_Share",,48)
For Each objItem in colItems
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_Share instance"
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "AccessMask: " & objItem.AccessMask
    Wscript.Echo "AllowMaximum: " & objItem.AllowMaximum
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "InstallDate: " & objItem.InstallDate
    Wscript.Echo "MaximumAllowed: " & objItem.MaximumAllowed
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path: " & objItem.Path
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "Type: " & objItem.Type
Next
0
 

Author Comment

by:HStrix
ID: 17111613
Thanks,
but I noticed that it does not work for foreign shares
using strComputer = "otherComputer"

How can this be achieved?
0
 
LVL 41

Expert Comment

by:graye
ID: 17111701
That's probably due to a Firewall issue...   The default setting for the built-in firewall for XP Service Pack 2 and beyond excludes remote administration.  Run the following on the remote PC to configure the firewall:

 netsh firewall set service RemoteAdmin enable

For additional information see:  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/connecting_through_windows_firewall.asp
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:HStrix
ID: 17111928
Thanks,
your cmd line executed successful
but the usage is still not possible.
'GetObject' cannot be used.

Using the network neighborhood it is possibloe to access the foreign shares without any problems.

So the result could be, wmi is NOT the favorite.



0
 
LVL 41

Expert Comment

by:graye
ID: 17112130
Hummm.... what exactly is the error message you're getting?
0
 

Author Comment

by:HStrix
ID: 17112367
The message is:
the computer does not exist or cannot be reached;
GetObject cannot be executed.
0
 
LVL 41

Expert Comment

by:graye
ID: 17112427
That still sounds like a firewall issue at the "remote" PC.   What is the operating system on that PC?
0
 

Author Comment

by:HStrix
ID: 17112905
The OS on the computer is XP-Home SP2, the firewall is not running.I'm running ZoneAlarm Pro on it.
The OS on the other[virtual]  computer is W2K SP4, it runs in a VM of VMware 5.5.1;
it accesses the internet through the XP-Home host.
And - as I said, using the neighborhood I can exchange data between both machines.
0
 

Author Comment

by:HStrix
ID: 17114552
In the meantime I tried to get my expected information using API (NetShareGetInfo) and ADSI too,
the result: no luck.
Always the same: for the foreign share I get Read-Only.
0
 

Author Comment

by:HStrix
ID: 17114563
I also need to say my computer are ion a workgroup, not in a domain.
0
 
LVL 41

Expert Comment

by:graye
ID: 17114660
The Remote Administration feature of WinXP Home Edition has been deliberatly disabled by Microsoft.

Therefore you will not be able to perform a "remote scan" of shares on a Home Edition PC.  However, you still should be able to perform that task when run locally.
0
 

Author Comment

by:HStrix
ID: 17114803
I checked more websites and I found a way:
     http://www.activevb.de/tipps/vb6tipps/tipp0646.html
Here the API NetShareEnum is used to accomplish my target.
This API enumerates all shares on a computer
and returns my expected result.
It also works in XP-Home.
Unfortunately it doesn't seem to be possible
to get the result without any enumeration...

I don't understand either why this API is working,
and the solutions with WMI, ADSI and NetShareGetInfo API do not.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question