?
Solved

I try to delete a remote shares by VBS

Posted on 2009-04-08
6
Medium Priority
?
304 Views
Last Modified: 2012-06-22
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.
0
Comment
Question by:Master-Squirrel
  • 3
4 Comments
 

Author Comment

by:Master-Squirrel
ID: 24095378
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
0
 

Author Comment

by:Master-Squirrel
ID: 24095919
Hmmm...It works only on XP. Why?
0
 
LVL 15

Accepted Solution

by:
qz8dsw earned 1000 total points
ID: 24110956
I would say your coming up against Vista's UAC.
You could try using UAC Elevation (as per http://www.winhelponline.com/articles/185/1/VBScripts-and-UAC-elevation.html)
Or as per another post on EE disable it completely (depending on your situation).
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/Windows_Vista/Q_22833413.html
0
 

Author Comment

by:Master-Squirrel
ID: 24117442
Great thanks! It works!!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

850 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