Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2006-07-14
12
279 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

829 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