Solved

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

Posted on 2006-07-14
12
278 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…

773 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