Solved

I try to delete a remote shares by VBS

Posted on 2009-04-08
6
287 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
6 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 250 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

825 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