Solved

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

Posted on 2006-07-14
12
275 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
 

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

709 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now