I have been using the IADsFileShare interface to create shares at work. After reading your question I decided to read up on it to see whether it was appropriate for deleting shares remotely instead. This says that it can represent shares remotely and here I found the code to do delete shares using this interface written in vbscript. I simply translated it to perl and tested it locally under Windows 2000. Unfortunately I only have one Windows machine so I can't test it remotely. It uses ADSI which I think you need to download and install in on NT4 but is already there under Windows 2000. I don't know about Win 9x. You didn't say what OS you were using.

Here is my perl translation

use Win32::OLE; my $share_name = "dev"; my $machine_name = "FIREBALL"; my $server = Win32::OLE->GetObject("WinNT://FIREBALL/lanmanserver") or die $!; $server->Delete("Fileshare", $share_name)

Note that this interface has a CurrentUserCount property that could tell you how many people are using the share.

Please let me know how it goes!


In reply to Re: Listing and removing mounted shares remotely? by blm
in thread Listing and removing mounted shares remotely? by Marza

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.