• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

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

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
HStrix
Asked:
HStrix
  • 7
  • 5
1 Solution
 
grayeCommented:
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
 
HStrixAuthor Commented:
Thanks,
but I noticed that it does not work for foreign shares
using strComputer = "otherComputer"

How can this be achieved?
0
 
grayeCommented:
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
Technology Partners: 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!

 
HStrixAuthor Commented:
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
 
grayeCommented:
Hummm.... what exactly is the error message you're getting?
0
 
HStrixAuthor Commented:
The message is:
the computer does not exist or cannot be reached;
GetObject cannot be executed.
0
 
grayeCommented:
That still sounds like a firewall issue at the "remote" PC.   What is the operating system on that PC?
0
 
HStrixAuthor Commented:
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
 
HStrixAuthor Commented:
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
 
HStrixAuthor Commented:
I also need to say my computer are ion a workgroup, not in a domain.
0
 
grayeCommented:
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
 
HStrixAuthor Commented:
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

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!

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now