Link to home
Start Free TrialLog in
Avatar of Master-Squirrel
Master-Squirrel

asked on

I try to delete a remote shares by VBS

Greetings, - )
I want to delete a remote share. I started from trying to delete local share with this code:
(look at the code)

This is a part of code (I exclused the part where I write to log file my results).

So when I opened my log file I see that all my shares where found but they are not deleted.

I tried to use "If Err.Number <> 0 Then"
but it didn't help.

I try to run it on MS Vista.
Avatar of Master-Squirrel
Master-Squirrel

ASKER

Hm...
That is my code:

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")
   
      
For Each ShareItem in colShares
            ShareItem.Delete                                    
Next
Hmmm...It works only on XP. Why?
ASKER CERTIFIED SOLUTION
Avatar of qz8dsw
qz8dsw
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great thanks! It works!!